Skip to main content

4Store with Snorql on Raspberry Pi

Problem

I need to access triple-store data for a work thing, but the data I have to test with isn't in their (sesame) triple store yet. There are RDF files, though.

Solution

Install 4Store on a pi (I had one with a default Raspbian running because it's the mumble server).

sudo apt-get install 4store

...then I set up the 4store with instructions from here:

sudo 4s-backend-setup saws
sudo 4s-backend saws
4s-httpd saws

then import the RDF files with a convoluted command:

curl --verbose --header 'Content-type: application/rdf+xml' --upload-file MSH_Thales_Trans.rdf --url 'http://localhost:8080/data/http%3A%2F%2Fwww.purl.org%2Fsaws%2Fontology%23'

(for each file - the url is the saws url encoded, the .rdf bit was done for each file).

Then fix the RDF, because rapper rejects it all. To validate the RDF I used this:


Okay, now I can see things on the pi: http://<pi ip address>:8080/test/

So, to help with queries I need snorql

There's no snorql package, but it's a simple ajax thing, a few webpages. I clone it from github, put it in 

/var/www/

...then discover (the hard way, via installing lighthttpd and having it not work) that I really need the rewrite rules in apache for some reason.

So:

sudo apt-get install apache2

One then has to make a sparql rewrite rule.

Edit:

/var/www/sparql/.htaccess

RewriteEngine on
RewriteBase /sparql/
RewriteRule ^(.*)$ http://<pi ip address>:8080/sparql/$1 [P]

...edit the default site file to add 

AllowOverride FileInfo

enable mod-rewrite, mod-proxy, and mod-proxy-http

sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http

...restart apache2...

sudo service apache2 restart

...you may also need to edit snorql.js to change:

this._endpoint = document.location.href.match(/^([^?]*)snorql\//)[1] + 'sparql';

...to this...

this._endpoint = document.location.href.match(/^([^?]*)snorql\//)[1] + 'sparql/';

Hey presto!

I now have snorql at:

http://<pi ip address>:8080/sparql/

...but the results are weird. This is because the PUT overwrites graphs, so using cURL to put in all the files individually results in a fucked-up graph. I kill the 4s-httpd service, then use:

4s-import saws AS2450-2.rdf Cod_Bodl_Dig_6.rdf Cod_Par_Gr_1168.rdf Cod_Vat_Gr_743.rdf Cod_Vind_Gr_Theol_149.rdf eBocC.rdf eMubB.rdf ETDodds.rdf HaciMahmud5683.rdf KFH.rdf MSH_Mun_Thales.rdf MSH_Thales.rdf MSH_Thales_Trans.rdf --model http://www.purl.org/saws/ontology#

...to import all the files at once. Restart the service, and it's looking good!

Comments

  1. the 4store debian package is not in jessie; if you use jessie with your raspi then add a line in /etc/apt/sources.list to include wheezy, update and install.
    debian archives unstable and testing have versions of 4store - if you encounter problems.

    ReplyDelete

Post a Comment

Popular posts from this blog

Chrome Extension: iPlayer to XMBC

There's a Chrome extension called Play To XBMC which adds a little button that will send a YouTube, Vimeo, or CollegeHumor video to XBMC - provided you have the YouTube plugin installed. This is a lot more convenient that using XBMC to search directly, if you don't have a keyboard plugged into the XBMC box. The XBMC iPlayer plugin suffers from the same problem that browsing/searching aren't easy without a keyboard, so I wondered if I could make a chrome extension that would do the same for iPlayer. Chrome extensions are packages of javascript, html, and image files that get unpacked by Chrome when they're installed. You make a Manifest file (which is a JSON file) that tells Chrome what icons to include, what sort of package it is, etc. The Play To XBMC extension is a browser one - the button is always there. I made mine page specific - it only appears on valid iPlayer episode pages. You do this by putting in a javascript page that runs in the background every time ...

Mumble and Murmur on Raspberry Pi

Problem:  Skype kind of sucks for games night things. Potential Solution: People have suggested ventrilo, etc., but murmur (the mumble server) will run on a raspberry pi. As I have a few of them, I reimaged an SD card with the newest raspbian, then followed the instructions here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=36&t=8615 If I put it in the DMZ, hopefully people from outside Nerdvana should be able to connect to it. It supports positional audio for games - I wonder if I could make a plugin that would just allow you to set your position, so that we could be around a virtual table with positional audio? ...Looks like there is: Mumble comes with a plugin for manually positioning audio. http://mumble.sourceforge.net/Games#Manual_Positional_Audio_Plugin