※ 本記事はnoteに投稿した記事を転載しています。
※ https://note.com/super_crow2005/n/n7bac2f980462?magazine_key=m1df32e6ef6e1
プロパティの定義の記述について述べる。述語「SはOに~する」、「SはOと~である」といった「~」のところである。
rdf:typeでhttp://www.w3.org/1999/02/22-rdf-syntax-ns#Property を指定するか、rdf:Propertyをタグとして先頭の鍵括弧で指定する。このことは、型付けノード要素として定義する、なんていう言い方ができるようだ。つまり、
<rdf:Description rdf:about="test.org/test/prop">
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
</rdf:Description>
または、
<rdf:Property rdf:about="test.org/test/prop"/>
ということである。
以前、ノード要素の属性の設定について、個物(インディビデュアル)の記述を示した。趙州さんについては以下のように書いた。
<owl:NamedIndividual rdf:about="http://www.test.org/20250615/test01#Jyoshu">
<rdf:type rdf:resource="http://www.semanticweb.org/20250615/food#person"/>
<food:eat rdf:resource="http://www.semanticweb.org/20250615/food#bf20250615"/>
<food:age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">61</food:age>
<food:birthyear rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1965</food:birthyear>
<food:prefecture xml:lang="ja">神奈川</food:prefecture>
<food:sex xml:lang="en">male</food:sex>
</owl:NamedIndividual>
ここにある、food:eat、food:age、food:birthyear、food:prefecture、food:sexがプロパティである。food:eatはインディビデュアルのURI(#bf20250615)を指定しており、他はデータを記載している。OWLとしてはowl:ObjectPropertyとowl:DatatypePropertyとして分けられるが、RDFとしてはどちらもrdf:Propertyである。
実際にプロパティの定義の記述は次のようになっている。
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/20250615/food#eat"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#age"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#birthyear"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#in_time"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#material"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#name"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#prefecture"/>
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/20250615/food#sex"/>
このように、プロパティのURIを指定しているだけである。ずさんなのだが、クラスやサブクラスが少ないうちは、とりあえずこのようなものでよいと思っている。実際に、オントロジーを作り始めた段階では、その対象とするアプリケーションの範囲であっても、その領域・分野といったものをよくわかっていないし、世界観もできていないものだ。またよく変更することもある。クラスの定義も同様なのだが、初めは捨てるつもりで作っていくくらいの気持ちでよいのかもしれない。
このように書きながらも、オントロジーを作って、修正して、改善していく過程のこととか、また典型的なオントロジーのパターン、上位オントロジーとかの説明は必要だと思った。それはまだ先だとも思った。先は長いのだろうか。
とはいえ、真面目に考えるのは必要なことだ。プロパティは述語なのであるから、まずはSVOのSとOとの関係を明らかにするのである。VにとってSは参照元とか呼び出し元といったもの、Oは参照先、呼び出し先といったもので、関数的に考えてSをドメイン(領域、定義域)、Oをコドメイン(余域、値域)と呼ぶ。
プロパティの定義において、rdfs:domainでドメインを、rdfs:rangeでコドメインのURIを指定する。ObjectPropertyやDatatypePropertyについても同じである。
クラスをttt1:CL_A、ttt1:CL_Bとして、ObjectPropertyのttt1:oprop、DatatypePropertyのttt1:dpropの定義を示す。名前空間ttt1:は"http://www.ttt.org/ttt1#" である。
<owl:Class rdf:about="http://www.ttt.org/ttt1#CL_A">
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.ttt.org/ttt1#oprop"/>
<owl:someValuesFrom rdf:resource="http://www.ttt.org/ttt1#CL_B"/>
</owl:Restriction>
</owl:equivalentClass>
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.ttt.org/ttt1#dprop"/>
<owl:allValuesFrom rdf:resource="http://www.w3.org/2002/07/owl#rational"/>
</owl:Restriction>
</owl:equivalentClass>
</owl:Class>
<owl:Class rdf:about="http://www.ttt.org/ttt1#CL_B"/>
<owl:ObjectProperty rdf:about="http://www.ttt.org/ttt1#oprop">
<rdfs:domain rdf:resource="http://www.ttt.org/ttt1#CL_A"/>
<rdfs:range rdf:resource="http://www.ttt.org/ttt1#CL_B"/>
</owl:ObjectProperty>
<owl:DatatypeProperty rdf:about="http://www.ttt.org/ttt1#dprop">
<rdfs:domain rdf:resource="http://www.ttt.org/ttt1#CL_A"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
</owl:DatatypeProperty>
クラスCL_Aの中で、owl:equivalentClass、owl:Restriction、owl:onPropertyといったプロパティがあるが、これらについてはOWLのクラス表現、プロパティ制約といったこととして後に述べる。
プロパティttt1:opropのドメインはttt1:CL_A、コドメインはttt1:CL_Bと、またttt1:dpropのドメインはttt1:CL_A、コドメインはxml:int(整数型)であることが分かるだろう。
ttt1:CL_Aの個物ttt1:a1を示す。
<owl:NamedIndividual rdf:about="http://www.ttt.org/ttt1#a1">
<rdf:type rdf:resource="http://www.ttt.org/ttt1#CL_A"/>
<ttt1:oprop rdf:resource="http://www.ttt.org/ttt1#b1"/>
<ttt1:dprop rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</ttt1:dprop>
</owl:NamedIndividual>