Skip to main content

How to use Turtle sparql php


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. Could you please find the error? I can't figure it out.


Source: Tips4all

Comments

  1. Seems like the predicate in the WHERE {} statement is missing something.

    For example did you mean vcard:latitude ?

    Currently it is

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


    How about :

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


    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.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.