Advertisement
mihaesandrei

Untitled

Nov 14th, 2018
3,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARQL 1.59 KB | None | 0 0
  1. PREFIX dbpedia: <http://dbpedia.org/resource/>
  2. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  3. PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  4. PREFIX nobel: <http://data.nobelprize.org/terms/>
  5. PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
  6. PREFIX owl: <http://www.w3.org/2002/07/owl#>
  7. #SELECT DISTINCT ?instance ?category ?laureate ?continent
  8. SELECT DISTINCT (COUNT(?instance) AS ?nr) ?continent
  9. WHERE {
  10.   ?instance a nobel:LaureateAward.
  11.   ?instance nobel:category ?category.
  12.   ?instance nobel:laureate ?laureate.
  13.   ?laureate dbpedia-owl:birthPlace ?birthPlace.
  14.   ?birthPlace rdf:type dbpedia-owl:Country;
  15.               owl:sameAs ?country
  16.   {
  17.     SELECT *
  18.     WHERE {
  19.         SERVICE <http://dbpedia.org/sparql>
  20.         {
  21.             ?country dbpedia-owl:abstract ?ABS.
  22.             FILTER LANGMATCHES(LANG(?ABS),'en').
  23.  
  24.             BIND(
  25.               IF(CONTAINS(?ABS,'Australia'),'Australia',
  26.               IF(CONTAINS(?ABS,'South America')|| CONTAINS(?ABS,'Costa Rica')|| CONTAINS(?ABS,'Guatemala'),'South America',
  27.               IF(CONTAINS(?ABS,'North America'),'North America',
  28.               IF(CONTAINS(?ABS,'Asia'),'Asia',
  29.               IF(CONTAINS(?ABS,'Africa'),'Africa',
  30.               IF(CONTAINS(?ABS,'Europe') || CONTAINS(?ABS,'United Kingdom'),'Europe',          
  31.                   'N/A')))))) AS ?continent)            
  32.       }
  33.     }
  34.  
  35.   }
  36.   FILTER (
  37.     ?category NOT IN (
  38.       <http://data.nobelprize.org/resource/category/Literature>,
  39.       <http://data.nobelprize.org/resource/category/Peace>
  40.     ) &&
  41.     ?continent IN ('Europe', 'Asia')
  42.   )
  43. }
  44. GROUP BY ?continent
  45. ORDER BY ?instance
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement