私は、このアートオントロジを使ってセマンティックWebプロジェクト(私はこのテーマについて完全に初心者です):http://spraakdata.gu.se/svedd/painting-ontology/painting.owl SPARQLとPHPライブラリARC2を使って作業しています。私は次のコードを使用しています。それは動作しますが、結果は完全ではありません:ARC2でオントロジーを照会する方法は?
<?php
include_once("arc2/ARC2.php");
$config = array(
/* db */
'db_name' => 'ontologia',
'db_user' => 'root',
'db_pwd' => '',
/* store */
'store_name' => 'arc_tests',
/* stop after 100 errors */
'max_errors' => 100,
);
$store = ARC2::getStore($config);
if (!$store->isSetUp()) {
$store->setUp();
}
/* LOAD will call the Web reader, which will call the
format detector, which in turn triggers the inclusion of an
appropriate parser, etc. until the triples end up in the store. */
//$store->query('LOAD <http://localhost/ontologia/painting2.owl.xml>');
$q = '
PREFIX painting: <http://spraakbanken.gu.se/rdf/owl/painting.owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE {
?subject painting:createdBy ?object;
rdfs:label ?title.
}';
$r = '';
$id = 0;
if ($rows = $store->query($q, 'rows')) {
/* display the results in an HTML table */
echo "<table border='1'>
<thead>
<th>#</th>
<th>(Subject)</th>
<th>title</th>
</thead>";
/* loop for each returned row */
foreach($rows as $row) {
print "<tr><td>".++$id. "</td>
<td>" . $row['subject']. "</td>".
"<td>" . $row['title']. "</td>";
}
echo "</table>" ;
}
else{
echo "No hay resultados";
}
//$rs = $store->query('...');
$p='';
if ($errs = $store->getErrors()) {
/* $errs contains errors from the store and any called
sub-component such as the query processor, parsers, or
the web reader */
foreach ($errs as $err) {
$p .= '<li>' . $err. '</li>';
}
echo $p;
}
?>
この場合、クエリは述語 "createdBy"を持つすべてのトリプルを探します。 私はちょうど2つの結果を得る:
をしかし、私はその述語ノイのみで多くの絵画があることがオントロジーで見ることができます。彼らはプロパティ「ラベル」、例えば「ゲルニカ」はありません。しかし:
<owl:NamedIndividual rdf:about="http://spraakbanken.gu.se/rdf/owl/painting.owl#GuernicaObj">
<rdf:type rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#Painting"/>
<rdf:type rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#Reference"/>
<hasIntendedUse rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#Attention"/>
<hasColor rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#Black"/>
<hasColor rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#Gray"/>
<hasCreationDate rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#GuernicaCreationDate"/>
<hasDimension rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#GuernicaHeight"/>
<hasRepresentation rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#GuernicaJPG"/>
<hasTitle rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#GuernicaTitle"/>
<displayedAt rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#InternationalExposition"/>
<hasCurrentLocation rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#MuseoReinaSofía"/>
<createdBy rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#PabloPicasso"/>
<hasPaintType rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#StandOil"/>
<hasColor rdf:resource="http://spraakbanken.gu.se/rdf/owl/painting.owl#White"/>
</owl:NamedIndividual>
いくつかの絵画は、特定の構造及び(ラベルまたはCREATEDBYなど)いくつかの重要な特性を持っているのが、他の人がそれを作るこれ、ありません処理するのが難しい。このようなオントロジーを検索するにはどうしたらいいですか?私は何か間違っているのですか?オントロジーはひどく建設されていますか?
ありがとうございます。問題は、結果として絵の名前が欲しいということです。私はオントロジーがひどく構成されていると思います。はい、あなたはsintaxに誤りがあります。それは問題のコードにしか書かれていませんでした。私はそれを修正しました。 – Redleafar