0

私はオントロジーを持っています

<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 を取得する方法を知りたいです。

4

1 に答える 1

1

rdfs:labelin OWL は注釈です。を取得するには、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());

getObjectPropertiesInSignature()owlapi (5) の最新 (1 年以上) バージョンでは非推奨です。そのため、 java-8streamのバージョンobjectPropertiesInSignatureの使用を検討してください。java-9は数日前にリリースされたので、機能を学ぶには良い時期です。stream

注: アノテーションはほとんど無料ですが、OWL2ではさらに標準化されているため、「事前定義されたセマンティクス」を持つアノテーションがあります。

于 2017-10-04T21:22:27.323 に答える