ændrew.com v8

Some fun with the semantic web

April 12, 2012

I’ve recently been playing with the semantic web (for the uninitiated, the semantic web is a structuring of web content in terms of what it depicts instead of just a bunch of linked text files) and have come up with the following two queries — let me know if you find these useful!

For SPARQL (I.e., dbpedia), the following should return how many competitors each country is sending to the London 2012 Olympics:

SELECT ?country ?competitors WHERE {
?s foaf:page ?country . 
?s rdf:type .
?s  "2012"^^ .
?s dbpprop:competitors ?competitors
} order by desc(?competitors)

See results by going here.

Meanwhile, if you want a MQL query (I.e., Freebase), use the following to give a comprehensive array of Golden Raspberry Award “winners”:

		query: {
			  "id": "/en/golden_raspberry_awards",
			  "type": "/award/award",
			  "category": [{
				"name": null,
				"name!=" : "Razzie Award for Worst Actor of the Decade", 
				"AND:name!=" : "Razzie Award for Worst Actress of the Decade",
				"nominees": [{          
					  "year": null,
					  "award_nominee": [],
					  "nominated_for": [],
					 "sort": "-year"
					}], /* nominees */
				"winners": [{
				  "s1:/type/reflect/any_master" : [{
					"type": "/award/award_winner",
					"name": null,
					"key" : [{
					  "namespace" : "/wikipedia/en",
					  "value": null,
					  "limit": 1
						}] /* key */
					}], /* award_winner */
				  "s2:/type/reflect/any_master" : [{
					"type": "/award/award_winning_work",
					"name": null,
					}] /* award_winning_work */
				}] /* winners */
			}] /* category */
		}  /* query */  	

Output here.

I’ll be writing a fairly comprehensive blog tutorial on this sometime in the next few weeks; follow me on Twitter for updates.


Ændrew Rininsland
© 2018 Ændrew Rininsland, except where otherwise noted.
Ændrew would like to thank Naomi Prescod-Green for a tremendous number of design and content suggestions over the course of this site's development.