OWL文件和protege的关系(加深理解版)
图1 代码分析
图2 ontology
RDF文件的代码如下:
<!--the namespace of Ontology-->
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:plants="http://www.linkeddatatools.com/plants#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<!--the header of Ontology-->
<owl:Ontology rdf:about="http://www.linkeddatatools.com/plants">
<dc:title>The LinkedDataTools.com Example Plant Ontology</dc:title>
</owl:Ontology>
<!-- OWL Class Definition -->
<owl:Class rdf:about="http://www.linkeddatatools.com/plants#planttype">
<rdfs:label>planttype</rdfs:label>
<rdfs:comment>The class of all plant types.</rdfs:comment>
</owl:Class>
<!-- OWL Subclass Definition - flowers -->
<owl:Class rdf:about="http://www.linkeddatatools.com/plants#flowers">
<rdfs:subClassOf rdf:resource="http://www.linkeddatatools.com/plants#planttype"/>
<rdfs:label>flowers</rdfs:label>
<rdfs:comment>Flowering plants, also known as angiosperms.</rdfs:comment>
</owl:Class>
<!-- OWL Subclass Definition - Shrub -->
<owl:Class rdf:about="http://www.linkeddatatools.com/plants#shrubs">
<rdfs:subClassOf rdf:resource="http://www.linkeddatatools.com/plants#planttype"/>
<rdfs:label>shrubs</rdfs:label>
<rdfs:comment>Shrubs, a type of plant which branches from the base.</rdfs:comment>
</owl:Class>
<!-- Define the family DatatypeProperty -->
<owl:DatatypeProperty rdf:about="http://www.linkeddatatools.com/plants#family"/>
<!-- Define the similarlyPopularTo ObjectProperty -->
<owl:ObjectProperty rdf:about="http://www.linkeddatatools.com/plants#similarlyPopularTo"/>
<!-- Define the instance of flowers_magnolia -->
<rdf:Description rdf:about="http://www.linkeddatatools.com/plants#magnolia">
<rdf:type rdf:resource="http://www.linkeddatatools.com/plants#flowers"/>
<plants:similarlyPopularTo rdf:resource="http://www.linkeddatatools.com/plants#orchid"/>
<plants:family>Magnoliaceae</plants:family>
</rdf:Description>
<!-- Define the instance of flowers_orchid -->
<rdf:Description rdf:about="http://www.linkeddatatools.com/plants#orchid">
<rdf:type rdf:resource="http://www.linkeddatatools.com/plants#flowers"/>
<plants:similarlyPopularTo rdf:resource="http://www.linkeddatatools.com/plants#magnolia"/>
<plants:family>Orchidaceae</plants:family>
</rdf:Description>
</rdf:RDF>
PS:可直接将该代码放于记事本中,将后缀名直接改为rdf格式,然后可以用protege5.0.0打开就可以看到图2
背景:由于现在在手工创建本体的时候,大多采用protege等软件,该软件屏蔽了代码层面的细节(类、属性、实例等的定义),我们可以直接通过概念层进行本体的搭建
所以导致我们队代码无法理解;其次当我们打开一个rdf或者OWL文件的时候,密密麻麻的代码让我们心乱如麻,根本分不清楚每一段代码都表达什么意思,完全淹没于字符当中。
故 大家可以按照图1中红色框分出来的部分(每一个框算一个部分),逐个框的往记事本中粘贴,粘完一部分马上保存,然后用protege打开看效果,这样的话我们就能够搞明白每段代码在protege当中对应的效果是什么,从而加深我们对OWL文件和protege软件的理解。