我有一个本体论
<owl:ObjectProperty rdf:about="http://purl.obolibrary.org/obo/BFO_0000050">
<owl:inverseOf rdf:resource="http://purl.obolibrary.org/obo/BFO_0000051"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
<oboInOwl:hasDbXref rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BFO:0000050</oboInOwl:hasDbXref>
<oboInOwl:hasOBONamespace rdf:datatype="http://www.w3.org/2001/XMLSchema#string">external</oboInOwl:hasOBONamespace>
<oboInOwl:id rdf:datatype="http://www.w3.org/2001/XMLSchema#string">part_of</oboInOwl:id>
<oboInOwl:shorthand rdf:datatype="http://www.w3.org/2001/XMLSchema#string">part_of</oboInOwl:shorthand>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">part of</rdfs:label>
</owl:ObjectProperty>我在试着提取所有的ObjectProperties
for (OWLObjectProperty obp : ont.getObjectPropertiesInSignature()){
System.out.println(obp.toString());
}这将打印ObjectProperty的名称,例如http://purl.obolibrary.org/obo/BFO_0000050。
我想知道如何获得rdfs:label,例如
发布于 2017-10-05 05:22:27
OWL中的rdfs:label是一个annotation。要获得label,您必须查询所需objectProperty的注释。
要显示本体的所有注释,您可以这样做:
final OWLOntology ontology = manager.loadOntologyFromOntologyDocument(new File(my_file));
final List<OWLAnnotation> annotations = ontology.objectPropertiesInSignature()//
.filter(objectProperty -> objectProperty.equals(the_object_property_I_want))//
.flatMap(objectProperty -> ontology.annotationAssertionAxioms(objectProperty.getIRI()))//
.map(OWLAnnotationAssertionAxiom::getAnnotation)//
.collect(Collectors.toList());
for (final OWLAnnotation annotation : annotations)
System.out.println(annotation.getProperty() + "\t" + annotation.getValue());在现代(一年多)版本的owlapi (5)中,getObjectPropertiesInSignature()已被弃用。所以请考虑使用java-8的stream版本objectPropertiesInSignature。java-9已经在几天前发布了,所以现在是学习stream功能的好时机。
注:注释几乎是免费的,但OWL2对其进行了更多的标准化,因此存在带有“预定义语义”的注释。
https://stackoverflow.com/questions/46533512
复制相似问题