我想从 DBpedia SPARQL API 获取有关人员的所有信息。第一个问题是,请求花费了太长时间。其次,我没有取回有关我所寻找的人的任何信息。我不知道我做错了什么?
我的代码:
require_once "EasyRdf.php";
require_once "html_tag_helpers.php";
// Setup some additional prefixes for DBpedia
EasyRdf_Namespace::set('category', 'http://dbpedia.org/resource/Category:');
EasyRdf_Namespace::set('dbpedia', 'http://dbpedia.org/resource/');
EasyRdf_Namespace::set('dbo', 'http://dbpedia.org/ontology/');
EasyRdf_Namespace::set('dbp', 'http://dbpedia.org/property/');
$sparql = new EasyRdf_Sparql_Client('http://dbpedia.org/sparql');
$result = $sparql->query(
'SELECT *
WHERE {
?person foaf:name ?name.
?person foaf:name ?name.
FILTER(regex(?person,"John Lennon"))
}
'
);
echo "<pre>";
print_r($result);
我的结果:
EasyRdf_Sparql_Result Object
(
[type:EasyRdf_Sparql_Result:private] => bindings
[boolean:EasyRdf_Sparql_Result:private] =>
[ordered:EasyRdf_Sparql_Result:private] =>
[distinct:EasyRdf_Sparql_Result:private] =>
[fields:EasyRdf_Sparql_Result:private] => Array
(
[0] => person
[1] => name
)
[storage:ArrayIterator:private] => Array
(
)
)