SparqlPress

SparqlPress explores the addition of an RDF store to the Wordpress weblogging system through PHP-based extensions, providing a basic Personal Semantic Web Aggregator that can integrate interesting data from nearby in the Web, exposing it to local and remote applications via the SPARQL query language and protocol.

See DanBriSlides for some motivations, SparqlingNaut for possible UI application.

The primary goal is to populate the local store with an interesting subset of the nearby Semantic Web, through discovery and crawling of RDF data from the websites (typically blogs; initially Wordpress blogs running the FOAF/SKOS plugin).

As there is not yet a full PHP Sparql parser or query engine, this will be prototyped using Redland and Redland's PHP bindings.

Related but different ideas:

Background Reading

Some things to know about... (todo: add links)

Usage Scenarios

SparqlPress should...

Example scenarios we hope to support:

TODOs

(in no real order...)

Development Notes

OK, We're talking to MySQL OK... and created a mysql-backed store. It made these tables in our 'wordpress' database:

| Bnodes                         |
| Literals                       |
| Models                         |
| Resources                      |
| Statements14932826769506100049 |

These are alongside the various sets of wordpress tables, eg.:

| sp1_categories                 |
| sp1_comments                   |
| sp1_linkcategories             |
| sp1_links                      |
| sp1_options                    |
| sp1_post2cat                   |
| sp1_postmeta                   |
| sp1_posts                      |
| sp1_users                      |

(where sp1_ is specified in wp-config.php).

So, do we try to relativise Redland to store things as sp1_Models, sp1_Resources, sp1_StatementsBlahBlahBlah? (is that it? or more tables needed ever?).

Probably yes we should, so installations don't conflict. OK here is a design: all Wordpress within one Mysql database share a common set of Redland mysql tables, and are kept distinct using different named storages, where the naming convention follows those used within this wordpress installation.

For example, our Wordpress install uses the sp1_ prefix for its Wordpress tables. So within Redland, the scoping is handled using the 'model' mechanism. So we have:

mysql> select * from Models;
+----------------------+-----------+
| ID                   | Name      |
+----------------------+-----------+
| 14932826769506100049 | db4       |
| 17733401352462907705 | sp1_test1 |
+----------------------+-----------+
2 rows in set (0.00 sec)

This was created using the following PHP:

sdrdf_load_module(); # function from spaqlTool.php
$world = librdf_php_get_world();
$storage=librdf_new_storage($world, 'mysql', 'sp1_test1', "new='yes',host='localhost',database='wordpress',user='wpuser',password='pwdhere'");

So. Let's consider the dataset scoping problem solved. Now, how to take an URL and put data into the store?

Next things:

# here we store some RDF in the database.
# Q? how to do it as a context?
$swpage='http://danbri.org/foaf.rdf';
$model = librdf_new_model($world, $storage, '');
$uri = librdf_new_uri($world, $swpage);
$parser = librdf_new_parser($world, 'raptor', 'application/rdf+xml', $nulluri);
librdf_parser_parse_into_model($parser, $uri, $uri, $model);

Does the 2nd $uri there set an implicit context? What query would list all contexts?

Each Model has a separate 'statements' table, eg. Statements14637794015643685849 (see Models table to map from the statement table number to the name eg. sp1_test2). Each time I run the loader, it adds yet more triples to the specified Model. Would be nice to replace tather than add...

Things to figure out:

Problems with Redland:

Some sample data to play with... What I'm using:

The SKOS parts look like this, where skos is [WWW] http://www.w3.org/2004/02/skos/core#

<foaf:Document rdf:about="http://www.w3.org/2004/OWL/">
        <dc:subject rdf:resource="#c24"/>
</foaf:Document>
<Concept rdf:about="#c30">
        <dc:identifier>30</dc:identifier>
        <prefLabel>Politics</prefLabel>
        <rdfs:label>Politics</rdfs:label>
        <inScheme rdf:resource="#scheme"/>
        <broader rdf:resource="#c1"/>
</Concept>

It worked first time:

here's the query:

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?label WHERE
(?node skos:prefLabel ?label)
(?node rdf:type skos:Concept)

Ugly hack notes: putting a copy of redland.so where my PHP expects it, rather than where the Redland+bindings I built put it. Probably should have tried telling Redland where my original php-config lived (ie. under apache) so it could have used the right php installation. Anyway it works for now.

mkdir -p /usr/local/apache/php/lib/php/extensions/no-debug-non-zts-20020429/
cp /usr/lib/php4/20020429/redland.so /usr/local/apache/php/lib/php/extensions/no-debug-non-zts-20020429/

SparqlPress is Semantic Web Vapourware for the masses... (if it gets coded up, will be linked from this page...)

last edited 2005-10-26 10:54:41 by bb-87-80-32-68