第 2 章 程度表現オントロジ
2.4 関連技術と相互運用性評価
2.4.1 程度表現オントロジと microformats hReview
hReview: hReview の情報を埋め込むブロックを指定し、以下の属性はこのブロ ック内に記述する。
<div class="hreview">...</div>
item type: 非必須。評価対象のタイプを表す。値は次のうちの一つ。
product|business|event|person|place|website|url
<span class="item"><a class="url fn" href="http://... ">The Postal Service: Give Up</a></span>
item info: 必須。評価対象に関する情報で、少なくとも名前("fn")を含まなければ
ならず、URI("url")を含むべきである。info type が person あるいは buisiness の場合、fnやurlはhCard(microformatsのvCard記述仕様)で記述し、info type
がeventの場合はhCalendarで記述する。
reviewer: 非必須。hCardで評価者を記述する。
dtreviewed: 非必須。評価日時を記述。ISO8601の日付表記でなければならない。
rating: 非必須。評価値を表す1.0から5.0の整数。下限はworstによって設定可
能(整数。デフォルトは 1.0)。上限は best によって設定可能(整数。デフォル トは5.0)。
description: 非必須。評価者の意見を記述したテキスト。XHTML マークアップ
を含んでよい。
tags: 非 必 須 。 評 価 者 が 評 価 対 象 に 関 連 付 け る キ ー ワ ー ド や フ レ ー ズ 。 microformatsのrel-tagを利用。rel-tagはmicroformatsの仕様で、aタグの属
性に rel=”tag”を付与することで、タグ(キーワードやテーマ)に対するリン
クであることを示す。例えば、レストランの評価であれば「料理」「雰囲気」「サ ービス」「値段」などの評価軸をタグ(キーワード)にすることが考えられ、そ れぞれのキーワードに関連したリンクとして、例えばwikipediaの該当キーワー ド項目のURLを記述する。
<li class="rating"><a href="http://en.wikipedia.org/wiki/Food" rel="tag">Food:
<span class="value">18</span>/<span class="best">30</span></a></li>
(5) 記述サンプル
商 品 レ ビ ュ ー の 記 述 例 を microformats hReview の web ペ ー ジ (http://microformats.org/wiki/hReview) より引用して示す。一番外側の<div>タグの
class属性にhreviewを記述することで評価情報を埋め込むブロックを指定している。
評価値は<abbr>タグの5つの*であるが、ratingの値としてtitle属性を用いて整数値 として5を記述している。このコンテンツのブラウザ上での表示を図2.4.2に示す。
<div class="hreview"><span class="item">
<a class="url fn" href="http://www.amazon.com/exec/obidos/ASIN/B000089CJI/">
<img src="http://images.amazon.com/images/P/B000089CJI.01._SCTHUMBZZZ_.jpg"
alt="Album cover photo: The Postal Service: Give Up. "
class="photo" />
The Postal Service: Give Up</a></span>
<div class="description"><p>
"The people thought they were just being rewarded for treating others as they like to be treated, for obeying stop signs and curing diseases, for mailing letters with the address of the sender... Don't wake me, I plan on sleeping in..."
</p><p>
"Nothing Better" is a great track on this album, too...
</p></div>
(<abbr class="rating" title="5">*****</abbr>) <p class="reviewer vcard">Review by
<a class="url fn" href="http://ifindkarma.com/blog/">Adam Rifkin</a>, <abbr class="dtreviewed" title="200502">February 2005</abbr>
</p>
</div>
図2.4.1 hReviewの記述例 (hReviewのwebサイトより引用)
図2.4.2 図2.4.1のコンテンツのブラウザ上での表示
(6) hReview作成補助ツール
hReview Creator[4]というhReview作成補助ツールが提供されている。スクリーン
ショットを図 2.4.3 に示す。ページ左側のフォームに必要項目を埋めると、右側のテ キストエリアに hReviewフォーマットのXHTML要素が生成される。ページの下段
にはXHTMLのプレビューが表示される。
図2.4.3 hReview Creator
2.4.1.2 RDFa (1) 目的
・ RDFのXHTMLへの埋め込み記述方法を規定する。
・ そもそも構造化データとなっている既存 HTML コンテンツを繰り返すことなく RDFを埋め込む。
・ もともとはXHTML2向けに設計されたが、XHTML1やSVG、非XHTMLでも 使えるようにする。
(2) 組織
・ W3CのSemantic Web Best Practices and Deployment Working Groupで開始 され、現在はHTML Working Groupの協力の下、Semantic Web Deployment
Working Group[5]で仕様策定が進められている。
(3) 活動状況
・ 最新バージョンは2006-05-16のW3C Working Draft[3] (2007年2月19日時点)。
・ Editor's Draft は2007-02-16[6]が最新。
(4) 記述フォーマット
・ RDF の構成要素は主語、述語、目的語である。<p>タグなどで、class 属性に主
語の型、aboutに主語のURIを記述し、そのブロック内に述語と目的語を記述す
る(なお、以下の例は全てRDFa のサイトより引用)。
<p class="cal:Vevent" id="xtech_conference_talk" about="#xtech_conference_talk">
…
</p>
・ 目的語がリテラルの場合、property属性に述語を記述し、目的語をその要素内容 として記述する。図 2.4.1 に示したhReview の rating の title 属性のように、
content属性でプロパティ値を記述することも可能。
I'm giving <span property="cal:summary">a talk at the XTech Conference about web wdgets</span>
<span property="cal:dtstart" content="20070508T1000-0500">May 8th at 10am</span>
・ 目的語がリソースの場合、<a>タグなどで rel 属性に述語を記述し、href 属性に リソースのURIを記述する。
This document is licensed under a
<a rel="cc:license" href="http://creativecommons.org/licenses/by-nc/2.5">
Creative Commons Non-Commercial License
</a>.
・ ブランクノードは、rel属性に述語を記述した入れ子構造で記述する。
<dl class="foaf:Person" about="#card"
<dt>Office Address</dt>
<dd rel="foaf:office">
<div rel="foaf:address">
<span property="foaf:address_line_1">77 Massachusetts Ave.</span><br />
...
(5) 記述サンプル
イベントに関する記述サンプルを (http://microformats.org/wiki/hReview) より引 用して示す。
<html xmlns:cal="http://www.w3.org/2002/12/ca/ical#"
xmlns:contact="http://www.w3.org/2001/vcard-rdf/3.0#">
…
<p class="cal:Vevent" about="#xtech_conference_talk">
I'm giving
<span property="cal:summary">
a talk at the XTech Conference about web widgets </span>,
on
<span property="cal:dtstart" content="20070508T1000-0500">
May 8th at 10am </span>.
</p>
…
<p class="contactinfo" about="http://example.org/staff/jo">
My name is
<span property="contact:fn">
Jo Smith </span>.
I'm a
<span property="contact:title">distinguished web engineer</span>
at
<a rel="contact:org" href="http://example.org">Example.org</a>.
You can contact me
<a rel="contact:email" href="mailto:[email protected]">via email</a>.
</p>
図2.4.4 RDFaの記述例 (RDFaのwebサイトより引用)
2.4.1.3 程度表現オントロジとhReviewの記述比較
図2.4.1に示したhReviewの商品レビューを、RDFaを用いて程度表現オントロジ(DEX)
で記述した例を図2.4.5に示す(比較のために図2.4.6に図2.4.1を再掲する)。
DEXは語彙に対する拡張性を持っている分だけ、名前空間に関する部分(宣言や接頭辞)
が記述増加になっているが、hReviewとほぼ同程度の記述量で記述可能である。
<html xmlns=”http://www.w3.org/1999/xhtml”
xmlns:dex=”http://www.net.intap.or.jp/INTAP/s-web/2007/03/dex#”>
<div class="dex:Rate">
<a rel=”dex:hasTheme” href="http://www.amazon.com/exec/obidos/ASIN/B000089CJI/">
<img src="http://images.amazon.com/images/P/B000089CJI.01._SCTHUMBZZZ_.jpg"
alt="Album cover photo: The Postal Service: Give Up."/>
The Postal Service: Give Up</a>
<div><p>
"The people thought they were just being rewarded for treating others as they like to be treated, for obeying stop signs and curing diseases, for mailing letters with the address of the sender... Don't wake me, I plan on sleeping in..."
</p><p>
"Nothing Better" is a great track on this album, too...
</p></div>
(<span rel=”dex:hasDegree”
href=” http://www.net.intap.or.jp/INTAP/s-web/2007/03/dex#Five”>*****</span>) <p>Review by
<a rel="dex:hasPublisher" href="http://ifindkarma.com/blog/">Adam Rifkin</a>, <span property="dex:hasDate" content="200502">February 2005</span>
</p>
</div>
</html>
図2.4.5 DEX(RDFa)による記述
<div class="hreview"><span class="item">
<a class="url fn" href="http://www.amazon.com/exec/obidos/ASIN/B000089CJI/">
<img src="http://images.amazon.com/images/P/B000089CJI.01._SCTHUMBZZZ_.jpg"
alt="Album cover photo: The Postal Service: Give Up. "
class="photo" />
The Postal Service: Give Up</a></span>
<div class="description"><p>
"The people thought they were just being rewarded for treating others as they like to be treated, for obeying stop signs and curing diseases, for mailing letters with the address of the sender... Don't wake me, I plan on sleeping in..."
</p><p>
"Nothing Better" is a great track on this album, too...
</p></div>
(<abbr class="rating" title="5">*****</abbr>) <p class="reviewer vcard">Review by
<a class="url fn" href="http://ifindkarma.com/blog/">Adam Rifkin</a>, <abbr class="dtreviewed" title="200502">February 2005</abbr>
</p>
</div>
図2.4.6 hReviewによる記述
2.4.2 程度表現オントロジへのセマンティックWeb技術(SPARQL, SWRL)の適用