※ 本記事はnote投稿の転載です。
※ https://note.com/super_crow2005/n/na4eb95d37b01?magazine_key=m1df32e6ef6e1
今回で、OWLの記述方法についての話は終わりである。一通り、オントロジーを記述することはできる、と思う。OWLファイルの注釈や実際のオントロジーの作り方といった話は、protégéの使い方を先に知っておいた方がよいであろう。
最後に、データタイププロパティにおいてデータを列挙にする方法を示しておく。
owl:DatatypePropertyはデータ値への関連(属性)を記述するためのプロパティであった。プロパティは、ドメインは呼び出しもとは、SVOのSなので、クラスである。コドメインがデータというものである。データの定義については、
(1) リテラルのデータ型(rdfs:Literal)
(2) XMLのデータ型(xsd:~)
(3) 列挙データ型(owl:oneOfによるデータ値のリスト)
(1)と(2)はRDFのプロパティの定義として示した。
(3)はもう少し細かく言うと、クラス公理やプロパティ公理の範囲や値を設定する\rdfs:Datatype>や<rdfs:range>の後に、<owl:oneOf>と繋ぎ、<rdf:List>と<rdf:rest>を繰り返してデータ値のリスト構造を作る。直接見た方が速いし、protegeで設定するなら、たとえば{1,2,3,4}などと書くだけでよいので、そんなに面倒な物でもない。
列挙型をプロパティ公理の設定のたびに記述するのは面倒なので、列挙型のデータ型rdfs:Datatypeを設定することとした。例を以下に示す。
列挙型のrdfs:Datatypeをttt:enum01とした。owl:DatatypePropertyやowl:Restrictionのところではttt:enum01を参照しているだけである。
<rdfs:Datatype rdf:about="http://ttt/ttt#enum01">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:oneOf>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">3</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">4</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
<rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">5</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</owl:oneOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>
<owl:DatatypeProperty rdf:about="http://ttt/ttt#enum_test">
<rdfs:range rdf:resource="http://ttt/ttt#enum01"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="http://ttt/ttt#hasLiteral">
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="http://ttt/ttt#has_value">
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:Class rdf:about="http://ttt/ttt#A">
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty rdf:resource="http://ttt/ttt#enum_test"/>
<owl:someValuesFrom rdf:resource="http://ttt/ttt#enum01"/>
</owl:Restriction>
</owl:equivalentClass>
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty rdf:resource="http://ttt/ttt#hasLiteral"/>
<owl:someValuesFrom rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>
</owl:Restriction>
</owl:equivalentClass>
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty rdf:resource="http://ttt/ttt#has_value"/>
<owl:someValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:Restriction>
</owl:equivalentClass>
</owl:Class>
<owl:NamedIndividual rdf:about="http://ttt/ttt#a1">
<rdf:type rdf:resource="http://ttt/ttt#A"/>
<ttt:enum_test rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">3</ttt:enum_test>
<ttt:hasLiteral rdf:datatype="http://www.w3.org/2000/01/rdf-schema#Literal">"abcdefg"</ttt:hasLiteral>
<ttt:has_value rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">5</ttt:has_value>
</owl:NamedIndividual>