SPARQL examples: Difference between revisions

(clean up)
(test)
Line 3: Line 3:
== Simple Queries ==
== Simple Queries ==
=== Complete Dependency Graph ===
=== Complete Dependency Graph ===
{{#widget:SPARQLquery|code=
#defaultView:Graph
#defaultView:Graph
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
Line 13: Line 12:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
}}
 


=== Central topics (topics with a high number of dependencies) ===
=== Central topics (topics with a high number of dependencies) ===
{{#widget:SPARQLquery|code=
#defaultView:Graph
#defaultView:Graph
PREFIX wd: <https://graphit.ur.de/entity/>
PREFIX wd: <https://graphit.ur.de/entity/>
Line 35: Line 33:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
}}
 


=== Advanced topics (topics with a high number of prerequisites) ===
=== Advanced topics (topics with a high number of prerequisites) ===
{{#widget:SPARQLquery|code=
#defaultView:Graph
#defaultView:Graph
PREFIX wd: <https://graphit.ur.de/entity/>
PREFIX wd: <https://graphit.ur.de/entity/>
Line 57: Line 54:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
}}


=== Topics that Max Mustermann has completed ===
=== Topics that Max Mustermann has completed ===
{{#widget:SPARQLquery|code=
#defaultView:Timeline
#defaultView:Timeline
PREFIX wd: <https://graphit.ur.de/entity/>
PREFIX wd: <https://graphit.ur.de/entity/>
Line 77: Line 72:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
}}
 
== Not yet implemented ==
 
=== Topics that Max Mustermann wants to complete ===
 
=== All topics in the CGBV course ===
 
=== Educational resources for learning Python ===
 
=== Stuff you need to learn if you want to write a tool that counts objects in an image ===

Revision as of 22:18, 5 May 2023

This page is automatically parsed by the query page to provide examples.

Simple Queries

Complete Dependency Graph

  1. defaultView:Graph

PREFIX wdt: <https://graphit.ur.de/prop/direct/> SELECT ?item ?itemLabel ?class ?classLabel ?image ?dependency ?dependencyLabel WHERE {

 ?item wdt:P1 ?dependency.
 ?item wdt:P2 ?class
 OPTIONAL{ ?item wdt:P9 ?image.}
 OPTIONAL{ ?class wdt:P9 ?image.}
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}


Central topics (topics with a high number of dependencies)

  1. defaultView:Graph

PREFIX wd: <https://graphit.ur.de/entity/> PREFIX wds: <https://graphit.ur.de/entity/statement/> PREFIX wdv: <https://graphit.ur.de/value/> PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX p: <https://graphit.ur.de/prop/> PREFIX ps: <https://graphit.ur.de/prop/statement/> PREFIX pq: <https://graphit.ur.de/prop/qualifier/>

SELECT ?dependency ?dependencyLabel ?prerequisites ?prerequisite ?prerequisiteLabel WHERE {

 {
 SELECT ?dependency ?dependencyLabel (COUNT(DISTINCT ?prerequisite) as ?prerequisites) WHERE {
     ?prerequisite wdt:P1 ?dependency.      
 } GROUP BY ?dependency ?dependencyLabel
 }
 ?prerequisite wdt:P1 ?dependency.
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}


Advanced topics (topics with a high number of prerequisites)

  1. defaultView:Graph

PREFIX wd: <https://graphit.ur.de/entity/> PREFIX wds: <https://graphit.ur.de/entity/statement/> PREFIX wdv: <https://graphit.ur.de/value/> PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX p: <https://graphit.ur.de/prop/> PREFIX ps: <https://graphit.ur.de/prop/statement/> PREFIX pq: <https://graphit.ur.de/prop/qualifier/>

SELECT ?prerequisite ?prerequisiteLabel ?dependencies ?dependency ?dependencyLabel WHERE {

 {
 SELECT ?prerequisite ?prerequisiteLabel (COUNT(DISTINCT ?dependency) as ?dependencies) WHERE {
     ?prerequisite wdt:P1 ?dependency.      
 } GROUP BY ?prerequisite ?prerequisiteLabel
 }
 ?prerequisite wdt:P1 ?dependency.
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}

Topics that Max Mustermann has completed

  1. defaultView:Timeline

PREFIX wd: <https://graphit.ur.de/entity/> PREFIX wds: <https://graphit.ur.de/entity/statement/> PREFIX wdv: <https://graphit.ur.de/value/> PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX p: <https://graphit.ur.de/prop/> PREFIX ps: <https://graphit.ur.de/prop/statement/> PREFIX pq: <https://graphit.ur.de/prop/qualifier/> SELECT ?topic ?topicLabel ?image ?date WHERE {

 BIND(wd:Q157 as ?user).
 ?user p:P12 ?statement.
 ?statement ps:P12 ?topic.
 ?statement pq:P19 ?date.
 OPTIONAL{ ?topic wdt:P11 ?image.}
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}

Not yet implemented

Topics that Max Mustermann wants to complete

All topics in the CGBV course

Educational resources for learning Python

Stuff you need to learn if you want to write a tool that counts objects in an image