Category Archives: RDF Query

sparqling days / iphoto rdf export

funny slide from Tuscany
Sparqling days in Tuscany was excellent fun and seems to have spawned enough interest to create a small community of developers – ‘the Gargonza Experiment‘. More of that later, but if you’re interested, do mail us – the infrastructure’s not quite there yet but we want to make something that’s completely open and interesting to anyone who wants to play with some (non-commercial) cross-sparqling experiments.
In between all the lovely food and wine I started hacking on a converter from iPhoto data to RDF so we could easily create some data for querying with Sparql. I started using XSLT over AlbumData.xml – bleugh – what horrible XML! and then realised that comments were not exported to AlbumData.xml, so I switched to Applescript to grab out the fields, which more or less works ok but involves a bit of string munging that’s probably somewhat specific to the way I put my photos online. I want to look in more detail about using SKOS for the keywords, but not done that yet.
Finally, I wanted to use the comments field from iPhoto to parse out people depicts data using nicknames from my foaffile. So in a dc:description field (the comment field from iPhoto) you might find
<foaf:Image rdf:about=”http://swordfish.rdfweb.org/photos/2005/04/14/2005-04-14-Images/9.jpg”&gt;

<dc:description>ericp and solid soup</dc:description>

</foaf:Image>
The python script I created using Sean B. Palmer’s very cool Pyrple API checks each word in that dc:description field and matches it against the foaf:nicks in my foaffile. The we can find out other stuff about the person, such as their name and mbox_sha1sum, and then put that information back in the image description file, like this:
<foaf:Image rdf:about=”http://swordfish.rdfweb.org/photos/2005/04/14/2005-04-14-Images/9.jpg”&gt;

<dc:description>ericp and solid soup</dc:description>
<foaf:depicts>
<foaf:Person>
<foaf:name>Eric Prud’hommeaux</foaf:name>
<foaf:mbox_sha1sum>e2d67791b2a0ce3441c0c770f94daa130b4e6d95</foaf:mbox_sha1sum>
<foaf:nick>ericp</foaf:nick>
</foaf:Person>
</foaf:depicts>
</foaf:Image>
I think Edd Dumbill used to do this for his photos but I’ve not found a writeup of it. Anyway, that’s where I got the idea from. I wonder if it might also work for places if we had some property like foaf:visited or somesuch.
It’s all been a bit of an education learning some bits of XSLT I didn’t know and learning applescript (this site was useful) and python (mostly using diveintopython).
All these experiments are available to play with (read the readme first), including the RDF output and my photos from the week. Also check out rdf4food wiki for better photos of that gorgeous part of Tuscany.
Update: Richard Newman reminded me of his iPhoto 4 plugin which is doing something similar. He’s doing a version for iPhoto 5 apparantly :)

TreeHugger

a tree hugger
Shellac (Damian Steer) has released a prelliminary version of TreeHugger, an RDFPath plugin thing for Saxon’s XSLT. Very cool indeed. The hope is that XML people will enjoy using RDF without having to see the syntax at all. What I want to persuade him to do now is a Squish to RDFPath converter; it’s not straightforward however – we will lose much of the functionality of XSLT which Saxon provides by passing off the RDFPath in one go to an RDF Query engine, although it should be much faster (and work with databases as well as files). At the moment it creates a tree out of the RDF file that Saxon can understand, so you get all the functionality. Much credit goes to Norm Walsh here for his RDFTwig which does something similar. I think it’s worth cloning the XPath syntax though, hopefully to persuade XSLT peple that RDF is actually very sensible. Unless it confuses them.