2012-01-18 64 views
7

我试图筛选此数据库写在龟如何使用龟SPARQL的PHP​​

@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']; 
?> 

该脚本返回没有错误,而不是结果。

回答

2

似乎WHERE {}语句缺少某些内容中的谓词。

例如,你的意思是vcard:latitude

目前,它是

$rows = SELECT ?x ?y WHERE { 
?x vcard: ?y. 
} 

如何:

$rows = SELECT ?x ?y WHERE { 
?x vcard:latitude ?y . 
} 

,可能有问题,如果没有前一段空间字符。注意我在上面添加了。至少这就是我在使用Python RDF库时遇到的情况。

+1

之前的空格字符应该没有关系。但是,谓词定义很重要;) – zazi 2012-03-07 18:21:41