获取推断对象属性断言隐士推理器

时间:2016-05-26 14:22:16

标签: java owl reasoning

假设我在Protege中创建了一些本体,并且有一个带有一些对象属性的类的实例,以及一个对象属性列表,如下图所示:

An individual of the class Device, "Email_Server", with the object property "realizes"

对象属性的层次结构如下:

Object Property Hierarchy

现在,当我打开Reasoner(Hermit)时,我得到了同一个人的以下断言对象属性:

Inferred Object Properties for the individual Email_server

当我点击推断对象属性“dependsUp”客户的解释时,我得到:

Explanation for the inferred Object Property "dependsUp" customer

我的问题是如何使用Java生成这个?我已经可以通过以下方式获得某个人的推断对象属性(这里不完整,但是它可以像我测试的那样工作):

for (OWLNamedIndividual namedIndividual : this.ontology.getIndividualsInSignature()) {
            if (subjectName.equals(namedIndividual.getIRI().getFragment())) {
                OWLObjectProperty objectProperty = fac.getOWLObjectProperty(IRI.create(propertyIRI));
                NodeSet<OWLNamedIndividual> namedIndividualSet = reasoner.getObjectPropertyValues(namedIndividual ,objectProperty);

                for (Node<OWLNamedIndividual> namedIndividualsInObjectPropertySet : namedIndividualSet) {
                    for (OWLNamedIndividual namedIndividualForObjectPropertySet : namedIndividualsInObjectPropertySet) {
                        for (OWLClassExpression owlClass : namedIndividualForObjectPropertySet.getTypes(this.ontology)){
                            if (owlClass.toString().split("#")[1].replace(">", "").equals(archiClass)) {
                                result.add(OWLOntologyUtils.getHumanInstanceName(this.ontology, namedIndividualForObjectPropertySet.getIRI().getFragment()));
// Result contains all the inferred object properties shown in the above pictures, so this code works. How can I access the explanation for one of the inferred object properties by the reasoner here?
                            }
                        }
                    }
                }

            }
        }

1 个答案:

答案 0 :(得分:1)

您可以使用InferredObjectPropertyAxiomGenerator

InferredObjectPropertyAxiomGenerator generator = new InferredObjectPropertyAxiomGenerator();
generator.createAxioms(owldatafactory, reasoner);