Flex: SPARQL Browser – Flex based dbPedia Semantic Web Explorer

SPARQL Explorer is an application which is a front end for the dbPedia SPARQL endpoint.

For the best explanation of what dbPedia is you should go to their website. I quote:

“DBpedia is a community effort to extract structured information from Wikipedia and to make this information available on the Web. DBpedia allows you to ask sophisticated queries against Wikipedia and to link other datasets on the Web to Wikipedia data.”

It is a Semantic Web of information linked together using RDF. The dataset available ranges from Flikr to Cyc.

The root of the idea for this application came from Slashdot. I came across this article which got me intrigued. I had a look at the dbPedia website and I noticed that there was an online application called SPARQL Explorer. A closer look using the Firebug ‘Net’ view for this web application and I saw that it was issuing queries to here. Some more digging and there is a definition of the protocol for sending SPARQL queries to the endpoint here.

Hmmm…I thought..I can issue a query and get results back in JSON or XML..that gives me an idea. What if I used the code for the Carrot2 browser to visualise queries from dbPedia? It might not only look cool but I could use it to test queries for any mashup I made against dbPedia.

I booted up Flex Builder 2 and came up with this. It issues queries using the same namespaces (read your SPARQL documentation folks) as SPARQL Explorer. The default query which it uses on startup is the same one from here. I hard coded it into the application as a first example. The query is inside a TextArea control so you can change it. Try some of the other queries on this page (section 1.3). The application has been set to fetch the results in XML form. I have nothing against the alternative of JSON except that it’s easier to parse XML data in Flex using E4X. E4X is built in to Flex and I can’t underestimate how handy it is. Mike Chambers has a tutorial on Flex and JSON here but as I say I’m not using it. Obligatory screenshot…(right click and view image for the full view).

Sample App

You can get the FB2 (NOT FB3) source code for this application here.

So I had an application which was able to send the same SPARQL queries as SPARQL Explorer. What now? My thinking was that I could adapt the code from the Carrot2 viewer to visiualise the query results so that’s what I did.

Sample App

(right click and view image for the full view).

You can access the application here. [UPDATE: This seems to be throwing an occasional error when it's fetching the result-set for some reason. Keep trying and it will eventually work :( I will investigate].

Again, try some of the other queries on this page (section 1.3).

This uses flexvizgraphlib visualisation component. The graphs are built by generating GML from the query results data.

The SPARQL queries issued use the same namespace PREFIX values as the test application and also SPARQL Explorer. An additional feature would be the ability to define these and maybe store them in the Flash player storage area (the same one used for the auto complete info from my CTV application). That way they would be there as you defined them each time you came back to the browser app. I have come to see this as a bit of an oversight I should probably address. The SPARQL prefix definitions are:


owl: www.w3.org/2002/07/owl#
xsd: www.w3.org/2001/XMLSchema#
rdfs: www.w3.org/2000/01/rdf-schema#
rdf: www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: xmlns.com/foaf/0.1
dc: purl.org/dc/elements/1.1
dbpedia2: dbpedia.org/property
dbpedia: dbpedia.org
skos: www.w3.org/2004/02/skos/core#

An interesting twist to this application is that I had to write a proxy script which resides on the server to serve up the requested xml from queries. The application in it’s raw form cannot access the SPARQL endpoint because of course you cannot issue an HTTPService request straight from your application to a remote url. I will post some more about this and go into details.

Some of the main features of the browser app are:

- Geared towards dbPedia

- Able to auto limit the resut size

- The resulting XML is displayed in the XML tab.

- You can view the result of clicking on a URI in the Browse tab using my IFrame control. Pretty cool!!

- Result nodes which share URI’s are linked on the graph so you can see what results are related (you can’t see this on a bog standard table output). If you look at the screenshot above you can see that default query demonstrates this. A blue star node indicates a URI, a blue circle a result and a gray star a binding.

I will publish the source as soon as I have tidied it up.

Comments

Leave a Reply