0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【オントロジー】(4)ノード要素の属性

Posted at

※ 本記事はnoteに投稿した記事を転載したものです。
https://note.com/super_crow2005/n/nf5e466a7fcaa

趙州さんに登場してもらう、彼は男であって、1965年生まれの61歳、神奈川県在住である。そんな趙州さん、朝起きたら坐禅する。これを1文で書いてみよう。

性別男、1965年生まれ、年齢61歳、住所(県)神奈川の趙州さんは、朝に坐禅を行う。

色々とごちゃごちゃしてしまったが、文の骨格は「趙州さんは坐禅する」である。ただセマンティック・ウェブのRDFトリプルでは目的語が必要なので、ここは「趙州さんは坐禅を行う」として坐禅を目的語にする。そして「朝に坐禅する」は「『朝の坐禅』を行う」と扱う。そしてこの朝の坐禅とは、趙州さんの朝におこなう具体的な活動のことである。

※ もちろん坐禅を人の一般的普遍的な行動の概念と考えてもよいが、ここでは、朝の活動の一種類として坐禅があると扱う。この問題は難しい。アプリケーションにおいて、何を普遍的として、そこから個物とするか。プログラム的にはクラスを用意して、データとして扱うかということであるが、存在として普遍的とするものを一貫させたいのである。

このようにすると、男、1965年、61歳、神奈川県というのは趙州さんの属性値であり、朝は活動の属性値と見做せるだろう。クラスとしてみると、人には性別、生年、年齢、住所(県)があり、活動には時節があるという属性がある、ということだ。
オントロジーでは、これらもプロパティであるが、OWLではデータプロパティとして扱う。これまでプロパティといっていたのは、クラスやインディビデュアルをコドメイン(値域)にとるオブジェクトプロパティという。データプロパティは数値や文字列などの決まったデータ型をコドメインとする。但しRDFの構文としては、S(subject)に対するVO(verb, object)のように、主語の子供のノードとして、つまりXMLの木構造としては、段付けされた構成要素として記述される。

インディビデュアルとしての趙州さんの記述
<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>

<owl:NamedIndividual rdf:about="http://www.test.org/20250615/test01#zazen">
  <rdf:type rdf:resource="http://www.semanticweb.org/20250615/food#activity"/>
  <food:in_time xml:lang="ja">朝</food:in_time>
</owl:NamedIndividual>

RDFの構文的なことではあるが、ノード要素が同じなら、それに関連する述語、目的語はまとめて記載する。

属性といっているデータプロパティの書き方はそこに示される通りである。XML的には括弧<>内のアトリビュート(属性)にデータ型(rdf:datatype)を指定して、テキスト要素としてデータ値を書く、というものである。オブジェクトプロパティがrdf:resourceでURIを指定しているのと対照的だろう。プロパティの記号については接頭辞でのURIであって、段付けしてまとめて並べている。

オントロジー的にSVO(SPO(subject predicate object))の記法で書くと、次のようになるだろう。

test01:Jyoshu rdf:type person .
test01:Jyoshu food:eat food:bf20250615.
test01:Jyoshu food:age 61 rdf:datatype xsd:integer .
test01:Jyoshu *food:birthyear 1965 rdf:datatype xsd:integer .
test01:Jyoshu food:prefecture 神奈川 rdf:datatype xsd:string xml:lang ja.
test01:Jyoshu food:sex male rdf:datatype xsd:string xml:lang en .
test01:zazen rdf:type food:activity .
test01:zazen rdf:food:in_timerdf:datatype xsd:string xml:lang ja .

このよう複数の文を並べて書くと、一文の複文にしたくなる。

test01:Jyoshu rdf:type person,
  food:eat food:bf20250615,
  food:age 61 rdf:datatype xsd:integer,
  food:birthyear 1965 rdf:datatype xsd:integer,
  food:prefecture 神奈川 rdf:datatype xsd:string xml:lang ja,
  food:sex male rdf:datatype xsd:string xml:lang en.

test01:zazen rdf:type food:activity,
  rdf:food:in_timerdf:datatype xsd:string xml:lang ja .

さて、クラス定義についてはどうすればよいか、気になると思うが、別の機会としたい。オントロジーとしてのクラス公理の記述方法に関することになるので、まだまだそこまではいかない。そうはいっても、Protegeを使えば、owlファイルの記述方法など気にせずにデータは作っていける。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?