如何使用 Turtle sparql php
我正在尝试过滤这个用 Turtle 编写的数据库,
@prefix : <http://www.essepuntato.it/resource/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix cs: <http://cs.unibo.it/ontology/> .
:pt0001
vcard:category "Poste e Telegrafi"
; vcard:fn "Ufficio Bologna 1"
; vcard:extended-address "Via Cairoli 9, Bologna BO, Italy"
; vcard:latitude "44.504192"
; vcard:longitude "11.338661"
; vcard:tel "051 243425"
; vcard:fax "051 244459"
; cs:opening "Mon, Tue, Wed, Thu, Fri: 0800-1330. Sat: 0800-1230."
; cs:closing "01-01, 01-06, P, LA, 04-25, 05-01, 06-02, 08-15, 11-01, 12-08, 12-25, 12-26: .".
我使用 arc2 api 因为 RAP 不起作用。 我编写了这段代码,但它不起作用:
<?php
/* ARC2 static class inclusion */
include_once('./arc2/ARC2.php');
/* MySQL and endpoint configuration */
$config = array(
/* db */
'db_host' => 'localhost', /* optional, default is localhost */
'db_name' => 'my_db',
'db_user' => 'user',
'db_pwd' => 'secret',
/* store name */
'store_name' => 'my_endpoint_store',
/* endpoint */
'endpoint_features' => array(
'select', 'construct', 'ask', 'describe',
'load', 'insert', 'delete',
'dump' /* dump is a special command for streaming SPOG export */
),
'endpoint_timeout' => 60, /* not implemented in ARC2 preview */
'endpoint_read_key' => '', /* optional */
'endpoint_write_key' => 'somekey', /* optional */
'endpoint_max_limit' => 250, /* optional */
);
/* instantiation */
/* instantiation */
$ssp = ARC2::getSPARQLScriptProcessor($config);
/* script evaluation */
$scr = '
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
PREFIX dbpedia2: <http://dbpedia.org/property/>
ENDPOINT "database.ttl"
$rows = SELECT ?x ?y WHERE {
?x vcard: ?y.
}
';
$ssp->processScript($scr);
echo $ssp->env['output'];
?>
脚本不返回错误,也不返回结果。
I'm trying to filter this database written in Turtle
@prefix : <http://www.essepuntato.it/resource/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix cs: <http://cs.unibo.it/ontology/> .
:pt0001
vcard:category "Poste e Telegrafi"
; vcard:fn "Ufficio Bologna 1"
; vcard:extended-address "Via Cairoli 9, Bologna BO, Italy"
; vcard:latitude "44.504192"
; vcard:longitude "11.338661"
; vcard:tel "051 243425"
; vcard:fax "051 244459"
; cs:opening "Mon, Tue, Wed, Thu, Fri: 0800-1330. Sat: 0800-1230."
; cs:closing "01-01, 01-06, P, LA, 04-25, 05-01, 06-02, 08-15, 11-01, 12-08, 12-25, 12-26: .".
I use arc2 api beacause the RAP doesn't work.
I wrote this code but it won't work:
<?php
/* ARC2 static class inclusion */
include_once('./arc2/ARC2.php');
/* MySQL and endpoint configuration */
$config = array(
/* db */
'db_host' => 'localhost', /* optional, default is localhost */
'db_name' => 'my_db',
'db_user' => 'user',
'db_pwd' => 'secret',
/* store name */
'store_name' => 'my_endpoint_store',
/* endpoint */
'endpoint_features' => array(
'select', 'construct', 'ask', 'describe',
'load', 'insert', 'delete',
'dump' /* dump is a special command for streaming SPOG export */
),
'endpoint_timeout' => 60, /* not implemented in ARC2 preview */
'endpoint_read_key' => '', /* optional */
'endpoint_write_key' => 'somekey', /* optional */
'endpoint_max_limit' => 250, /* optional */
);
/* instantiation */
/* instantiation */
$ssp = ARC2::getSPARQLScriptProcessor($config);
/* script evaluation */
$scr = '
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
PREFIX dbpedia2: <http://dbpedia.org/property/>
ENDPOINT "database.ttl"
$rows = SELECT ?x ?y WHERE {
?x vcard: ?y.
}
';
$ssp->processScript($scr);
echo $ssp->env['output'];
?>
The script returns no error and not a result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎 WHERE {} 语句中的谓词缺少某些内容。
例如,您的意思是
vcard:latitude
吗?目前是
怎么样:
如果句号前面没有空格字符,可能会出现问题。请注意,我在上面添加了这一点。至少这是我在使用 Python RDF 库时所经历的。
Seems like the predicate in the WHERE {} statement is missing something.
For example did you mean
vcard:latitude
?Currently it is
How about :
And there may be problems if there is no space character before the period. Notice I added that above. At least that's what I experienced when using Python RDF libraries.