如何使用 owlexplanation 项目获得不一致的解释 [英] How to get an explanation for an inconsistency using the owlexplanation project

查看:78
本文介绍了如何使用 owlexplanation 项目获得不一致的解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 Matthew Horridge 在 GitHub 上的 owlexplanation 项目的问题.

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

在README文件中有如下代码:

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

请有人解释一下参数entailment的确切类型是什么?我不太明白我们得到的解释是什么.我正在寻找在我的本体不一致时给我解释的代码.

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.

推荐答案

entailment 参数是您试图确定蕴涵如何发生的公理.

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

为了解释不一致,您可以按照自述文件中的建议使用不同的工厂.我写了一个例子,它使用 OWLExplanation 的 1.1.2 版和 JFact 的 1.2.1 版(我需要一个推理器来测试这个;任何推理器都可以).

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

这篇关于如何使用 owlexplanation 项目获得不一致的解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆