sparql-examples

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

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

092

rq turtle/ttl

Event aspect: topic scores

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 wikibase: <http://wikiba.se/ontology#>
# Topics of works authored by people associated with an event

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

SELECT ?score ?topic ?topicLabel ?topicDescription
WITH {
  SELECT
    DISTINCT ?person
  WHERE {
    {
      # speaker, organizer, program committee member
      target: wdt:P823 | wdt:P664 | wdt:P5804 ?person .
    }
    UNION
    {
      # participant
      ?person wdt:P1344 | ^wdt:P710 target: .
    }
    UNION
    {
      # author
      ?person ^wdt:P50 / wdt:P1433 / wdt:P4745 target: .
    }
  }
} AS %people  
WITH {
  SELECT
    (SUM(?score_) AS ?score) ?topic
  WHERE {
    {
      target: wdt:P921 ?topic .
      BIND(50 AS ?score_)
    }
    UNION
    {
      INCLUDE %people
      ?person ^wdt:P50 / wdt:P921 ?topic .
      BIND(1 AS ?score_)
    }
    UNION
    {
      target: ^wdt:P4745 / ^wdt:P1433 / wdt:P921 ?topic .
      BIND(7 AS ?score_)
    }
  }
  GROUP BY ?topic
} 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(?score)
LIMIT 200

graph TD