0

这是代表艺术家、音乐家和音乐热门信息的猫头鹰本体

<rdf:RDF xml:base="http://www.semanticweb.org/ontologies/2013/3/MyArt">
  <owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt"/>
  <!-- 
       ///////////////////////////////////////////////////////////////////////////////////////
       //
       // Object Properties
       //
       ///////////////////////////////////////////////////////////////////////////////////////
  -->
  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#hasComposed -->
  <owl:ObjectProperty rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#hasComposed">
    <rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#hasCreated"/>
  </owl:ObjectProperty>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#hasCreated -->
  <owl:ObjectProperty rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#hasCreated"/>

  <!-- 
       ///////////////////////////////////////////////////////////////////////////////////////
       //
       // Classes
       //
       ///////////////////////////////////////////////////////////////////////////////////////
  -->

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#ArtisticWork -->
  <owl:Class rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#ArtisticWork"/>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#Composition -->
  <owl:Class rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#Composition">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#ArtisticWork"/>
  </owl:Class>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#MusicalHit -->
  <owl:Class rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#MusicalHit">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#Composition"/>
  </owl:Class>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#Person -->
  <owl:Class rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#Person"/>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#PopularMusician -->
  <owl:Class rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#PopularMusician">
    <owl:equivalentClass>
      <owl:Restriction>
        <owl:onProperty rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#hasCreated"/>
        <owl:someValuesFrom rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#MusicalHit"/>
      </owl:Restriction>
    </owl:equivalentClass>
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#Person"/>
  </owl:Class>

  <!-- 
       ///////////////////////////////////////////////////////////////////////////////////////
       //
       // Individuals
       //
       ///////////////////////////////////////////////////////////////////////////////////////
  -->

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#imagine -->
  <owl:NamedIndividual rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#imagine">
    <rdf:type rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#MusicalHit"/>
  </owl:NamedIndividual>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#jealousGuy -->
  <owl:NamedIndividual rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#jealousGuy">
    <rdf:type rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#MusicalHit"/>
  </owl:NamedIndividual>

  <!-- http://www.semanticweb.org/ontologies/2013/3/MyArt#lennon -->
  <owl:NamedIndividual rdf:about="http://www.semanticweb.org/ontologies/2013/3/MyArt#lennon">
    <rdf:type rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#Person"/>
    <hasComposed rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#imagine"/>
    <hasComposed rdf:resource="http://www.semanticweb.org/ontologies/2013/3/MyArt#jealousGuy"/>
  </owl:NamedIndividual>

</rdf:RDF> 
4

1 回答 1

0

将本体加载到OntModel中,然后您可以使用OntModel#listObjectPropertiesOntModel#listClasses来获取对象属性和类。但是,您需要从后者中过滤掉未命名的类,因为listClasses它会返回一个遍历所有类的迭代器,而不仅仅是命名类。对于该过滤,看起来您可以使用各种OntClass#isXXX方法,例如,OntClass#isComplementClass检查类是命名类还是非命名类表达式。

如果您是 Jena 的新手,Apache Jena页面有很多资源和文档可以帮助您入门。

于 2013-04-24T14:30:45.017 回答