这是猫头鹰本体,代表艺术家,音乐家和音乐点击的信息
<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>
答案 0 :(得分:0)
将本体加载到OntModel
,然后您可以使用OntModel#listObjectProperties
和OntModel#listClasses
来获取对象属性和类。但是,您需要从后者中过滤掉未命名的类,因为listClasses
会返回所有类的迭代器,而不仅仅是命名类。对于该过滤,看起来您可以使用各种OntClass#isXXX
方法,例如OntClass#isComplementClass
来检查类是命名类还是非命名类表达式。
如果您是Jena的新手,Apache Jena页面有很多资源和文档可以帮助您入门。