sparqling international calling codes

The other day I was looking for a list of international calling codes. Since most of them are listed in Wikipedia, it occurred to me it would be easy to get all that information in a nice easy to use format by querying DBPedia with SPARQL. So I wrote a very light weight SPARQL client (source code available here). Download the jar and you can then run the following query:

hjs@bblfish:0$ java -jar Sparql.jar > results.n3

PREFIX dbp: <http://dbpedia.org/property/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 

CONSTRUCT {  ?cntry dbp:callingCode ?code ;
                    rdfs:label ?name . 
} WHERE {
        ?cntry dbp:callingCode ?code .
        OPTIONAL { ?cntry rdfs:label ?name . }
}


\^d
That is after typing the command line java -jar Sparrql.jar > results.n3 I pasted the SPARQL query (in blue above) and ended the input with control-d, which on unix is the end-of-file character. This sent the query to DBPedia, and returned a long list of answers which were place in results.n3 of which the first set is
<http://dbpedia.org/resource/Abu_Dhabi_%28emirate%29> <http://www.w3.org/2000/01/rdf-schema#label> "\\u963F\\u5E03\\u624E\\u6BD4\\u914B\\u957F\\u56FD\\""@zh ,
		"Abu Dhabi (emirate)"@en ,
		"Abu Dhabi (emirato)"@it ,
		"\\u0410\\u0431\\u0443-\\u0414\\u0430\\u0431\\u0438 (\\u044D\\u043C\\u0438\\u0440\\u0430\\u0442)\\""@ru ;
	<http://dbpedia.org/property/callingCode> "971-2"@en .

In the above case the calling code should proabaly not be tagged with an @en. So the data still needs to be cleaned up a little at present. It would be nice to be able to quickly fix the data when one notices something like this. Most of the other results are in xsd:integer format, which I think is also not quite right. The literal string is a better representation of a calling code I think.

Anyway the data is easy to clean up. And we have an example of a very simple but useful query.

Comments:

Stimulated by this item and since I'm currently exploring the application of XQuery for these tasks, I wrote up the results in the XQuery Wikibook I'm writing - in fact I ended up scaping Wikipedia as the most accurate listing.

Posted by Chris Wallace on March 01, 2008 at 04:20 AM CET #

A very nice flash viewer can be found here:

http://ccgi.arutherford.plus.com/website/flex/dbPedia/sparqlQueryViewer/

Henry

Posted by Henry Story on March 26, 2008 at 09:21 AM CET #

Post a Comment:
Comments are closed for this entry.
About

bblfish

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today