Being a consumer of semantic data I thought creating a SPARQL endpoint would be an interesting exercise. It would require having some data to publish as well as working with a SPARQL library. For data, I chose a set of mileage information that I have been collecting on my cars for the last 5 years. For technology, I decided to use the Joseki SPARQL Server, since I was already using Jena.
For those who want to skip the “how” and see the result, the SPARQL endpoint along with sample queries and a link to the ontology and data is at: http://monead.com/semantic/query.html
The first step in this project was to convert my mileage spreadsheets into triples. I looked briefly for an existing ontology in the automobile domain but didn’t find anything I could use. I created an ontology that would reflect my approach to recording automobile mileage data. My data records the miles traveled between fill-ups as well as the number of gallons used. I also record the car’s claimed MPG as well as calculating the actual MPG.
The ontology reflects this perspective of calculating the MPG at each fill-up. This means that the purchase of gas is abstracted to a class with information such as miles traveled, gallons used and date of purchase as attributes. I abstracted the gas station and location as classes, assuming that over time I might be able to flesh these out (in the spreadsheet I record the name of the station and the town/state).
A trivial Java program converts my spreadsheet (CSV) data into triples matching the ontology. I then run the ontology and data through Pellet to derive any additional triples from the ontology. The entire ontology and current data are available at http://monead.com/semantic/data/HybridMileageOntologyAll.Inferenced.xml.
It turns out that the ontology creation and data conversion were the easy parts of this project. Getting Joseki to work as desired took some time, mostly because I couldn’t find much documentation for deploying it as a servlet rather than using its standalone server feature. I eventually downloaded the Joseki source in order to understand what was going wrong. The principle issue is that Joseki doesn’t seem to understand the WAR environment and relative paths (e.g. relative to its own WAR).
I had two major PATH issues: 1) getting Joseki to find its configuration (joseki-config.ttl); and 2) getting Joseki to find the triple store (in this case a flat file).