2

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.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73

2 Answers2

5

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);
  }
}
Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • It seems what exactly i need. I downloaded OWLExplanation and JFact and everything works ok but i get an error "type ExplanationGenerator does not take parameters". Have you any idea why? – Katerina Dimitraki Oct 19 '15 at 13:24
  • Which version are you using? Make sure you don't have multiple versions in the classpath – Ignazio Oct 19 '15 at 14:30
  • Could you please tell me when you run the example above, your project had only the libraries 1.1.2 of OWLExplanation and version 1.2.1 of JFact ? – Katerina Dimitraki Oct 20 '15 at 09:16
  • Yes, and their maven dependencies - owlapi 3.5 I believe – Ignazio Oct 20 '15 at 11:12
  • I have added just the following libraries: jfact-1.2.1, owlapi-distribution-3.5.0, owlexplanation-1.1.2, telemetry-1.0.0. And i get the error message "typeExplanationGenerator does not take parameters". I would be really grateful if you have any idea why i get this error. I tried to adapt the "InconsistentOntologyExplanationGeneratorFactory" to the code of the README file but still i get error for that class. – Katerina Dimitraki Oct 20 '15 at 13:50
  • Make sure the import for ExplanationGenerator is org.semanticweb.owl.explanation.api.ExplanationGenerator. There is a class of the same name in OWLAPI but you don't want to use it. – Ignazio Oct 20 '15 at 13:57
1

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>
Kenny Cason
  • 497
  • 5
  • 17