Wikidata:Synia:venue-topic

From Wikidata
Jump to navigation Jump to search

Synia: venue-topic

[edit]
PREFIX target1: <http://www.wikidata.org/entity/Q4744266>
PREFIX target2: <http://www.wikidata.org/entity/Q1492760>

SELECT DISTINCT ?description ?value ?valueUrl
WHERE {
  {
    BIND(1 AS ?order)
    BIND("Venue" AS ?description)
    BIND(target1: AS ?iri)
    BIND(SUBSTR(STR(?iri), 32) AS ?q) 
    ?iri rdfs:label ?value_string . 
    FILTER (LANG(?value_string) = 'en')
    BIND(COALESCE(?value_string, ?q) AS ?value)
    BIND(CONCAT("#venue/", ?q) AS ?valueUrl)
  }
  UNION
  {
    BIND(2 AS ?order)
    BIND("Topic" AS ?description)
    BIND(target2: AS ?iri)
    BIND(SUBSTR(STR(?iri), 32) AS ?q) 
    ?iri rdfs:label ?value_string . 
    FILTER (LANG(?value_string) = 'en')
    BIND(COALESCE(?value_string, ?q) AS ?value)
    BIND(CONCAT("#topic/", ?q) AS ?valueUrl)
  }
} 
ORDER BY ?order
Try it!

Recently published works

[edit]
PREFIX target1: <http://www.wikidata.org/entity/Q4744266>
PREFIX target2: <http://www.wikidata.org/entity/Q1492760>

SELECT DISTINCT
  (xsd:date(?publication_datetime) AS ?publication_date)

  ?work ?workLabel 
  (CONCAT("#work/", SUBSTR(STR(?work), 32)) AS ?workUrl)
  ?workDescription
WHERE {
  ?work wdt:P1433 target1: ;
        wdt:P921 # This is pretty expensive: / (wdt:P31| wdt:P279 | wdt:P361 | wdt:P1269)*
            target2: ;
        wdt:P577 ?publication_datetime .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?publication_datetime)
LIMIT 500
Try it!

Top topics through time

[edit]
#defaultView:AreaChart

PREFIX target1: <http://www.wikidata.org/entity/Q4744266>
PREFIX target2: <http://www.wikidata.org/entity/Q1492760>

SELECT
  ?year
  ?works
  ?topic ?topicLabel
WITH {
  SELECT 
    ?work
  WHERE {
    ?work wdt:P1433 target1: ;
          wdt:P921 target2: .
  }
} AS %works
WITH {
  SELECT
    (COUNT(?work) AS ?count)
    ?topic
  WHERE {
    INCLUDE %works
    ?work wdt:P921 ?topic .
  }
  GROUP BY ?topic
  ORDER BY DESC(?count)
  LIMIT 5
} AS %topics
WITH {
  SELECT
    ?year 
    (COUNT(?work) AS ?works)
    ?topic
  WHERE {
    INCLUDE %works
    INCLUDE %topics
    ?work wdt:P921 ?topic ;
          wdt:P577 ?publication_datetime .
    BIND(STR(YEAR(?publication_datetime)) AS ?year)
  }
  GROUP BY ?year ?topic
} AS %result
WHERE {
  INCLUDE %result
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?year
Try it!