sparql-examples

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

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

084

rq turtle/ttl

Event aspect: people

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#>
PREFIX target: <http://www.wikidata.org/entity/Q133457282>

SELECT
  (?number_of_publications AS ?works)
  ?person ?personLabel ?personDescription
  ?roles
  ?example_work ?example_workLabel
WITH {
  SELECT
    (GROUP_CONCAT(DISTINCT ?role; separator=", ") AS ?roles) ?person
  WHERE {
    {
      # speaker added directly in the target item
      target: wdt:P823 ?person .
      # BIND(wd:Q9379869 AS ?role)
      BIND("speaker" AS ?role)
    }
    UNION
    {
      # speaker inferred from presentation items related to the event-target
      ?presentation wdt:P823 ?person; wdt:P5072 target: 
      BIND("speaker" AS ?role)
    }
    UNION
    {
      # organizer
      target: wdt:P664 ?person .
      #BIND(wd:Q2029941 AS ?role)
      BIND("organizer" AS ?role)
    }
    UNION
    {
      # participant
      ?person wdt:P1344 | ^wdt:P710 target: .
      BIND("participant" AS ?role)
    }
    UNION
    {
      # editor
      ?person ^wdt:P98 / wdt:P4745 target: .
      BIND("editor of proceedings" AS ?role)
    }
    UNION
    {
      # author
      ?person ^wdt:P50 / wdt:P1433 / wdt:P4745 target: .
      BIND("author" AS ?role)
    }
    UNION
    {
      # program committee member
      target: wdt:P5804 ?person .
      BIND("program committee member" AS ?role)
    }
  }
  GROUP BY ?person
} AS %people  
WITH {
  SELECT
    (COUNT(?work) AS ?number_of_publications)
    ?roles
    ?person (SAMPLE(?work) AS ?example_work)
  WHERE {
    INCLUDE %people .
    ?person wdt:P31 wd:Q5.
    OPTIONAL { ?work wdt:P50 ?person . }
  }
  GROUP BY ?roles ?person
} AS %results
WHERE {
  INCLUDE %results
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,de,es,fr,jp,no,ru,sv,zh". }
}
ORDER BY DESC(?number_of_publications)
LIMIT 10000

graph TD