1

OWL-APIを使用してオントロジーから既存のクラスを取得するにはどうすればよいですか?これは私のオントロジーの断片です:

<owl:Class rdf:ID="StringDocu">
  <owl:equivalentClass>
    <owl:Restriction>
      <owl:someValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
      <owl:onProperty rdf:resource="#hasContent"/>
    </owl:Restriction>
  </owl:equivalentClass>
  <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >String Docu</rdfs:label>
  <rdfs:subClassOf rdf:resource="#Docu"/>
  <owl:disjointWith rdf:resource="#URIDocu"/>
  <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >This class concerns a docu with the content specified as common text.</rdfs:comment>
</owl:Class>

私はこのコードから始めます:

String ontologyUri = "http://mysite.com/my_ontology.owl";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.createOntology(IRI.create(ontologyUri));
OWLDataFactory factory = manager.getOWLDataFactory();

StringDocuそして今、私はクラスを取得したいと思います。どうすればこれを入手できますか?

4

2 に答える 2

2

質問で示したコードから続けて、次のようにクラスへの直接参照を取得できます(クラスURIは「http://mysite.com/my_ontology.owl#StringDocu」であると想定しています):

OWLClass stringDocuClass = factory.getOWLClass(IRI.create("http://mysite.com/my_ontology.owl#StringDocu"))

これにより、目的のクラスへの直接参照が得られ、そこから取得できます。

お役に立てれば!

于 2010-12-30T16:21:34.840 に答える
1

これにより、ロードしたオントロジーで参照されているすべてのクラスが得られると思います。

String ontologyUri = "http://mysite.com/my_ontology.owl";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.createOntology(IRI.create(ontologyUri));
Set <OWLClass> classes = ontology.getClassesInSignature();

次に、そのセットで必要なものを処理/フィルタリング/検索できますOWLClass

于 2010-07-21T09:40:07.433 に答える