librdfutil

Since last year I have been storing metadata about my photos, and other stuff like the twilight data, in a Redland triple store, backed by the MySQL storage implementation I wrote. I have been writing various PHP scripts for maintaining and querying the various graphs, and I found that there were a few basic tasks I kept implementing, writing the same code over and over again. At one point I finally started factoring them out into a common “library”, librdfutil (syntax highlighted version).

Most of the functions are only helpful in a PHP and/or MySQL environment, but a few of them might make it into the core Redland API at some point if other people find them useful and we can persuade Dave Beckett to include them.

The current version of this library is 0.0.1 (this entry will server as the changelog).

  • librdfutil_mysql_cbd_original_lite: Add the original CBD (without reification) for a node object to a model.
  • librdfutil_mysql_cbd_lite: Add revised CBD (without reification) for a node object to a model.
  • librdfutil_strings_to_node: Create a new librdf_node from a set of strings.
  • librdfutil_stringset_to_statement: Create a new librdf_statement from a set of strings.
  • librdfutil_tuple_to_statement: Create a new librdf_statement from a database tuple.
  • librdfutil_model_to_string: Get a serialised representation of a model, in R3X or Turtle syntax.
  • librdfutil_stream_to_string: Get a serialised representation of a stream of statements, in R3X or Turtle syntax.
  • librdfutil_node_to_turtle_string: Generate Turtle syntax fragment for node.
  • librdfutil_node_to_hash: Get a string hash (the MySQL ID) of a node object.
  • librdfutil_strings_hash: Get a string hash (the MySQL ID) of a node.

A few additional notes:

  • The MySQL specific functions, the ones that start with librdfutil_mysql, require ADODB.
  • In case anyone is wondering about the naming of the CBD functions, I expect to implement the full specification(s) at a later date — or perhaps someone else will contribute them…
  • At some point, a pretty API overview with usage examples will be created, for easy reference.

Comments, bug reports, and suggestions are as always much appreciated. Thanks to Russell Cloran for initial thoughts and comments on the pre-release version.

5 thoughts on “librdfutil

  1. How exactly are you adding the metadata? By hand? Via a custom app? By writing the queries directly? It’s very good, however you do it – a lot of info.

  2. Phil,

    I’m assuming you are referring to my photos, in which case the primary tool I use is http://www.wasab.dk/morten/2003/11/annotate/ — and more recently e.g. http://www.wasab.dk/morten/2004/08/select/?uri=http://www.wasab.dk/morten/2004/08/photos/eire/5/index.rdf, although that’s not quite polished yet.

    Also, a bunch of (mostly Perl) scripts, catch a glimpse at http://www.wasab.dk/morten/2004/08/photos/eire/5/Makefile, it’s not pretty but it works…

    My intention is to improve (on) these tools, I’ll make sure to write it up when I do.

  3. Yes, I was talking about your photos. Sorry for being obscure. :)

    It’s a really interesting approach (and a very technical one :). How best to annotate images is something that keeps bothering me. Currently I maintain a central RDF store of people, places etc. each of which has a foaf:nick (should probably be dc:subject). I then insert a list of nicks like [phil, paris] into the JPEG comment block of an image using JAlbum and then my JAlbum templates do a lookup in my data store and generate per-image RDF from there (as well as the HTML album, from which the nicks are stripped and the plain description also in the comment block left), making it a lot more del.icio.us-like in concept, but I don’t really have any good way of maintaining my central RDF store.

    This is the approach which is working best for me at the moment (and my non-geek girlfriend can understand putting names in square brackets, so all her photo-albums have RDF equivalents too).

    Anyway, sorry for the slight ramble. :)

  4. You’re right, my “solution” is quite technical, it’s designed for a technical user, me! :-)

    Your solution sounds really friendly, the only real problem I can think of is disambiguating people/places with the same names/nicks.

Comments are closed.