After FoafCamp and EuroFoo, I felt enthusiastic about coding again and sorted out some bugs in wh4 (more), an IRC bot. Basically I’d half implemented a new design which had two new features:
- on the fly creation of new query-based commends
- very simple query routing
The former uses this sort of syntax:
wh4, new shortcut !yourpets is select ?name, ?pet, ?espece where (foaf:mbox_sha1sum ?person ?mbox) (foaf:name ?dog ?pet) (pet:fedBy ?dog ?feeder) (foaf:mbox_sha1sum ?feeder ?mbox) (foaf:name ?person ?name) (pet:species ?dog ?espece) and ?name ~ "$1" using foaf for http://xmlns.com/foaf/0.1/ pet for http://purl.org/stuff/pets/
The ‘$1’ is just the variable you give the bot, e.g.
That gets substituted in and send directly to my restful interface to the database, which has an html version for testing queries.
The query routing is very simple and sort of dorky but seems to work ok. It uses an invented syntax in RDF/XML for describing that a database contains particular predicates, and then for any given query matches it against the list of predicates for a database it knows about; if the first database can’t answer the query it passes it to a second, chosen randomly. It doesn’t work for queries with clauses without predicates in them, and I never got it working for datasources that don’t use RDF queries e.g. Jim Ley’s airports datasource where you just send it a keyword for the query.
FWIW the Java source is available, and the bot is running on various channels on freenode, including #whwhwhwh and #foaf.
What it really needs is something that maybe the DAWG will provide – a standard means of accessing an RDF databases via http….