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

java - 获取推断的对象属性断言隐士推理程序-LMLPHP

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

java - 获取推断的对象属性断言隐士推理程序-LMLPHP

现在,当我打开(隐士)推理机时,我得到以下针对同一个人的断言对象属性:

java - 获取推断的对象属性断言隐士推理程序-LMLPHP

单击推断对象属性“ dependsUp”客户的说明时,将得到:

java - 获取推断的对象属性断言隐士推理程序-LMLPHP

我的问题是如何使用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?
                            }
                        }
                    }
                }

            }
        }

最佳答案

您可以使用InferredObjectPropertyAxiomGenerator

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

10-08 14:25