OWLAPI 4.1x + 限制 + 示例

OWLAPI 4.1x + Restrictions + example

您好,我关注的是 http://owlapi.sourceforge.net/owled2011_tutorial.pdf to understand and attempt to parse an ontology in OWL2/RDF. I'm wondering how to obtain restrictions provided within a class and the code example in the tutorial as well as that in the github code https://github.com/owlcs/owlapi/blob/version4/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorialowled2011/TutorialSnippetsTestCase.java 似乎没有显示有效示例。 PDF 似乎具有较旧的逻辑,github 中的示例似乎已注释掉代码。任何想法我都能够获取并打印 class 的属性 - 我将如何为复杂属性执行此操作,即如果我在 class 中有以下类型的限制:

<rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="AAA"/>
            <owl:someValuesFrom>
                <owl:Class>
                    <owl:intersectionOf rdf:parseType="Collection">
                        <owl:Restriction>
                            <owl:onProperty rdf:resource="BBB"/>
                            <owl:someValuesFrom rdf:resource="111"/>
                        </owl:Restriction>
                        <owl:Restriction>
                            <owl:onProperty rdf:resource="CCC"/>
                            <owl:hasValue rdf:datatype="xsd;string">SOME VALUE</owl:hasValue>
                        </owl:Restriction>
                    </owl:intersectionOf>
                </owl:Class>
            </owl:someValuesFrom>
        </owl:Restriction>
    </rdfs:subClassOf>

我将如何以编程方式解析它。我想看看 API 中的 methods/classes 我应该看什么,因为我是 OWL 和链接数据中的行话的新手。

从 class 的 IRI 开始,例如“http://example.com/startpoint”,您将:

  • 获取一个OWLClass实例:OWLClass c = owldatafactory.getOWLClass(IRI.create("http://example.com/startpoint"));
  • 从声明 ontology 中检索此 class 的所有超classes:Collection<OWLSubClassOfAxiom> axioms = ontology.getSubClassAxiomsForSubClass(c);
  • 对于每个公理,访问超级class:for(OWLSubClassOfAxiom ax:axioms){ OWLClassExpression levelOne = ax.getSuperClass();

在您的示例中,这是对 AAAsomeValuesFrom 限制。

为了探索对任何深度级别的限制,您要做的是编写一个 OWLClassExpressionVisitor(例如,通过扩展 OWLClassExpressionVisitorAdapter class)。在您链接的示例中,一个这样的 class 是 RestrictionVisitor extends OWLClassExpressionVisitorAdapter.

如果我没听错你的描述,你就是在 'properties of a class' 之后 - 通常的意思是输入 class 是域的一部分的属性。在此示例中,唯一这样的 属性 是 AAA,因此您无需更深入的访问即可找到它们。这个定义的复杂之处在于 AAA 的范围,它由另外两个 class 表达式组成。