如何使用 owlexplanation 项目获得不一致的解释
How to get an explanation for an inconsistency using the owlexplanation project
我有一个关于 Matthew Horridge 在 GitHub 上的 owlexplanation 项目的问题。
README 文件中有以下代码:
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);
有人可以解释一下参数 entailment
的类型到底是什么吗?我不太明白我们得到解释的东西。
当我的 ontology 不一致时,我正在寻找能给我解释的代码。
entailment
参数是您试图确定蕴含如何发生的公理。
为了解释不一致,您可以按照 README 中的建议使用不同的工厂。我写了一个示例,它使用了 OWLExplanation
的 1.1.2 版和 JFact 的 1.2.1 版(我需要一个推理机来测试这个;任何推理机都可以)。
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);
}
}
https://github.com/matthewhorridge/owlexplanation 处显示的 Maven 依赖项当前似乎不存在。是否有准确的 Maven 条目可用?
这是上面页面说要使用但找不到的内容:
<dependency>
<groupId>net.sourceforge.owlapitools</groupId>
<artifactId>owlexplanation</artifactId>
<version>1.0.0</version>
</dependency>
我有一个关于 Matthew Horridge 在 GitHub 上的 owlexplanation 项目的问题。
README 文件中有以下代码:
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);
有人可以解释一下参数 entailment
的类型到底是什么吗?我不太明白我们得到解释的东西。
当我的 ontology 不一致时,我正在寻找能给我解释的代码。
entailment
参数是您试图确定蕴含如何发生的公理。
为了解释不一致,您可以按照 README 中的建议使用不同的工厂。我写了一个示例,它使用了 OWLExplanation
的 1.1.2 版和 JFact 的 1.2.1 版(我需要一个推理机来测试这个;任何推理机都可以)。
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);
}
}
https://github.com/matthewhorridge/owlexplanation 处显示的 Maven 依赖项当前似乎不存在。是否有准确的 Maven 条目可用?
这是上面页面说要使用但找不到的内容:
<dependency>
<groupId>net.sourceforge.owlapitools</groupId>
<artifactId>owlexplanation</artifactId>
<version>1.0.0</version>
</dependency>