Demo 1b

Note: This recipe does not currently work on GitHub Pages.

This page demonstrates a relatively simple SPARQLy GUIs recipe. It accepts user input, creates a SPARQL query and sends it to DBpedia, then displays the results in tabular and graphic form.

The query asks for the most populous countries in the world, based on the populationEstimate attribute. To give the demonstration a try, set the Row Limit (if desired), then click the “Run Query” button.

Output

DBpedia’s information is harvested from Wikipedia, which is hand-edited by volunteers. So, certain values below may be incorrect or even missing. For example, some of the listed “countries” below may look peculiar and some expected countries (eg, USA) may not be present.

Table

Graph

To keep the graph headings reasonable, we divide the values by 1,000,000 and round the result. So, for example, a heading of 600 represents a human population estimate of 600,000,000. Hover over a bar to see the country name and full population estimate.

Implementation Notes

The source code for the SPARQLy GUIs pages is located at:

https://github.com/RichMorin/SPARQLy-GUIs/tree/gh-pages

SPARQL template

Each SPARQL query has a fixed function. In order to use queries for varying tasks, we need to generate appropriate queries. We do this by means of a query template, written in a combination of SPARQL and Handlebars. Variable information is provided by client-side code, based on user input, etc.

The following template, in particular, defines several parts of the query:

Liquid syntax error: Unknown tag ‘raw’

SPARQL query

Here is the actual SPARQL query, as sent to DBpedia:

This will be a SPARQL query...