sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

116

rq turtle/ttl

Organization aspect: page production

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#defaultView:BarChart

PREFIX target: <http://www.wikidata.org/entity/Q104785223>

# Pages per year bar chart of an organization
SELECT
  ?year
  (SUM(?pages_per_author) AS ?number_of_pages)
  ?researcher ?researcherLabel
WITH {
  SELECT 
    DISTINCT ?researcher
  WHERE {
    ?researcher wdt:P108 | wdt:P463 | (wdt:P1416 / wdt:P361*) target: .
  }
} AS %researchers
WITH {
    SELECT
      ?researcher ?work ?year
      (SAMPLE(?pages) / COUNT(?researcher_of_paper) AS ?pages_per_author)
    WHERE {
      INCLUDE %researchers
      
      ?work (wdt:P50 | wdt:P2093) ?researcher_of_paper .
      
      # Disabled to only look on scholarly articles
      # ?work wdt:P31 wd:Q13442814 .
      
      ?work wdt:P50 ?researcher ;
            wdt:P1104 ?pages ;
            wdt:P577 ?date . 
      BIND(STR(YEAR(?date)) AS ?year) 
    } 
    GROUP BY ?work ?researcher ?year
} AS %results
WHERE {
  INCLUDE %results
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
GROUP BY ?year ?researcher ?researcherLabel
ORDER BY ?year

graph TD