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]
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!
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.
ReplyDeletedebian archives unstable and testing have versions of 4store - if you encounter problems.