簡體   English   中英

OWL:從現有的Antology中獲取類

[英]OWL: get Class from an existent Antology

如何使用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類。 我怎么能得到這個?

從問題中顯示的代碼繼續,您可以按如下方式直接訪問該類(假定您的類URI為“ http://mysite.com/my_ontology.owl#StringDocu”):

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

這樣可以直接引用您要上的課程,然后可以從那里上課。

希望這可以幫助!

我認為這將為您提供加載的本體中引用的所有類:

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集合進行所需的處理/過濾/查找。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM