在OWLAPI中,有没有什么直接的方法可以找到本体中使用的所有IRI,这些IRI没有被标识为实体,即没有被声明,也没有在允许它们被标识为特定实体类型的上下文中使用?希望有类似于OWLOntology.signature()的东西,但什么也没看到。
这种情况的一个例子出现在BFO2.0 (http://purl.obolibrary.org/obo/bfo.owl)中:
<rdf:Description rdf:about="http://example.com/bfo-spec-label">
<obo:IAO_0000119>Person:Alan Ruttenberg</obo:IAO_0000119>
</rdf:Description>在这里,http://example.com/bfo-spec-label只是一个未知实体类型的“裸”IRI,因此不会出现在本体签名中。
发布于 2018-02-14 00:03:22
我找不到任何优雅的方法来找到所有这些赤裸裸的IRI,但是可以通过查找所有可能出现的地方来找到它们。一个简单的方法看起来像这样:私有列表findBareIRIs(OWLOntology onto) { List bares =新的ArrayList();
// bare IRIs can occur as AnnotationSubjects, AnnotationObjects or the domain/range of AnnotationProperties
List<OWLAnnotationAssertionAxiom> asserts = OWLAPIStreamUtils.asList(onto.axioms(AxiomType.ANNOTATION_ASSERTION));
List<OWLAnnotationPropertyDomainAxiom> domains = OWLAPIStreamUtils.asList(onto.axioms(AxiomType.ANNOTATION_PROPERTY_DOMAIN));
List<OWLAnnotationPropertyRangeAxiom> ranges = OWLAPIStreamUtils.asList(onto.axioms(AxiomType.ANNOTATION_PROPERTY_RANGE));
//check the subject and values of each AnnotationAsertion
for (OWLAnnotationAssertionAxiom ax : asserts) {
OWLAnnotationSubject subj = ax.getSubject();
OWLAnnotationValue value = ax.getValue();
if (subj.isIRI()) {
bares.add((IRI) subj);
}
if (value.isIRI()) {
bares.add((IRI) value);
}
}
// check the domain and ranges of each AnnotationProperty
for (OWLAnnotationPropertyDomainAxiom ax : domains) {
bares.add(ax.getDomain());
}
for (OWLAnnotationPropertyRangeAxiom ax : ranges) {
bares.add(ax.getRange());
}
return bares;}
https://stackoverflow.com/questions/48714072
复制相似问题