Thursday, March 20, 2008

RDF, SPARQL, and Lisp

One of my current projects is to investigate the possible interactions between Slate and Profiles In Terror. Now, Slate's knowledge representation is rooted in the Many-Sorted Logic, and PiT, a Semantic Web application, in RDF. My understanding is that PiT has a SPARQL interface, and so I've been exploring my options for working with SPARQL in Lisp.


Ideally, there would be some system that allowed me to parse and generate SPARQL queries locally, to send queries to SPARQL endpoints, and to process the results in some way. Note that I am not looking for a SPARQL engine and RDF store combination (i.e., a local RDF store with SPARQL query support). Searching for RDF and SPARQL on CLiki informs me of


Wilbur

The Wilbur Semantic Web Toolkit for CLOS seems to be in stand-still between versions. Wilbur seems to provide tools for managing a local RDF store, and for querying it with a Wilbur-specific API. Wilbur doesn't look quite like what I'm looking for, though it's something to be aware of for some applications, I suppose. There are, or at least were, people using Wilbur, since CLiki mentions a number of packages which build on Wilbur, including

twinql

Twinql is a parser and query engine for the SPARQL RDF query language, built on the Wilbur Semantic Web toolkit. At first, I thought that I might be able to use twinql to parse SPARQL locally, and indeed, twinql does parse SPARQL into an s-expression format. However, twinql is built on Wilbur, and that's more dependency that I really want.


So, I seem to be in a position where I'll be writing a SPARQL parser. The grammar is LL(1), and so it wouldn't be too hard to write it manually, but for the moment I've put a grammar together that is accepted by LispWork's defparser parser generator. There are some open-source parser generators for Lisp out there, and if I end up distributing this code (which would be nice) I would probably try to use one of those, or recode the parser directly. Lexing is a bit of a hairier issue. I found only one lexer generator, Michael Parker's CLAWK/REGEX/LEXER, but it depends on his REGEX package, and it's not clear to me (from the website) whether, or how, Unicode character ranges are handled. Which leaves me writing a SPARQL lexer by hand as well.


Once I can play with SPARQL natively in Lisp (which also means an s-expression syntax that can be converted to SPARQL, but that should be much easier), I'll probably turn to Edi Weitz's DRAKMA to handle communicating with SPARQL endpoints. Then it will be time to address the issue of processing the results (which will probably be in XML).


Monday, February 11, 2008

Introduction

Greetings, visitor. I am a doctoral student in Computer Science at Rensselaer Polytechnic Institute. My academic research focuses on logic and reasoning based Artificial Intelligence, and personal interests include music, logic, philosophy, languages, religion, theology, and combinations of the above. This area will, I hope, at least, provide me with a place to refine and record thoughts, and, in some cases, a place for some discussion. I guess I'll see how it all turns out.