如何使用 OWL-API 检索有关本体的断言

问题描述 投票:0回答:1

我的本体有以下三元组,其中主语是本体本身。 Protégé 在“活动本体”选项卡(“本体标题”部分)中将它们可视化为“注释”。

<http://myOntology/testOnto> rdf:type owl:Ontology ;
    <http://purl.org/dc/elements/1.1/creator> "Andrea"@it ;
    <http://purl.org/dc/elements/1.1/title> "test"@it ;
    rdfs:label "Andrea"@it .

如何使用 OWL API 检索它们?

owl-api
1个回答
0
投票

OWLOntology
实现了
HasAnnotations
接口,这些是本体本身的注释。因此,您可以使用
annotations
(或
annotationsAsList
)方法来实现:

StringDocumentSource source = new StringDocumentSource("""                
                <http://myOntology/testOnto> rdf:type owl:Ontology ;
                    <http://purl.org/dc/elements/1.1/creator> "Andrea"@it ;
                    <http://purl.org/dc/elements/1.1/title> "test"@it ;
                    rdfs:label "Andrea"@it .""");
OWLOntologyManager ontologyManager; // Init ontology manager
OWLOntology loaded = ontologyManager.loadOntologyFromOntologyDocument(source);
List<OWLAnnotation> annotations = loaded.annotationsAsList();
System.out.println(annotations);
© www.soinside.com 2019 - 2024. All rights reserved.