query-77ca9507061b38add4ce17f447038dec

rq turtle/ttl

TODO

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX target: <http://www.wikidata.org/entity/Q115632712>
SELECT
  (STR(FLOOR(?year_/10)) AS ?year)
  (COUNT(?work) AS ?number_of_publications)
  # Work type used to color the bar chart
  ?type

WHERE {
  {
     {
  # Find works with the topic. Also report the year
  SELECT
    ?work (MIN(?years) AS ?year_) (1 AS ?dummy) (SAMPLE(?article_type_) AS ?article_type)
  WHERE {
    ?work wdt:P921 / (wdt:P1433*/wdt:P279*  ) target: .
    ?work wdt:P577 ?dates .
    BIND(YEAR(?dates) AS ?years) .
    ?work wdt:P31 ?article_type_ .
  }
  GROUP BY ?work 
}    ?article_type rdfs:label ?type . FILTER (LANG(?type) = "es")
  }
  UNION
  {
     {
  SELECT ?year_ WHERE {
    # default values = 0
    ?year_item wdt:P407 wd:Q577 . 
    ?year_item wdt:P585 ?date .
    BIND(YEAR(?date) AS ?year_)
  }
}    BIND("_" AS ?type)
  }
   {
  # Find earliest publication year
  SELECT (MIN(?year_) AS ?earliest_year) WHERE {
     {
  # Find works with the topic. Also report the year
  SELECT
    ?work (MIN(?years) AS ?year_) (1 AS ?dummy) (SAMPLE(?article_type_) AS ?article_type)
  WHERE {
    ?work wdt:P921 / (wdt:P1433*/wdt:P279*  ) target: .
    ?work wdt:P577 ?dates .
    BIND(YEAR(?dates) AS ?years) .
    ?work wdt:P31 ?article_type_ .
  }
  GROUP BY ?work 
}  }
  GROUP BY ?dummy
}  BIND(YEAR(NOW()) AS ?this_year)
  FILTER (?year_ >= ?earliest_year && ?year_ <= ?this_year && ?year_ >= YEAR("1860-01-01"^^xsd:dat))
}
GROUP BY ?year_ ?type
ORDER BY ?year_

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v13("?article_type") v8("?article_type_") v12("?date") v6("?dates") v13("?dummy") v13("?earliest_year") v14("?number_of_publications") v13("?this_year") v13("?type"):::projected v5("?work"):::projected v13("?year") v13("?year_"):::projected v11("?year_item") v13("?years") a1((" ")) a2((" ")) a3((" ")) a4((" ")) c11(["wd:Q577"]):::iri c6(["wd:Q115632712"]):::iri f0[["?year_ >= ?earliest_year?year_ <= ?this_year?year_ >= year-from-dateTime(s1860-01-01^^<http://www.w3.org/2001/XMLSchema#dat>')"]] f0 --> v13 f0 --> v13 f0 --> v13 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v11 --"wdt:P407"--> c11 v11 --"wdt:P585"--> v12 bind1[/"year-from-dateTime(?date)"/] v12 --o bind1 bind1 --as--o v13 bind2[/"'_'"/] bind2 --as--o v13 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f3[["?type = 'es'"]] f3 --> v13 v5 --"wdt:P921"--> a1 a1 --"wdt:P1433"--> a2 a2 --"wdt:P279"--> c6 v5 --"wdt:P577"--> v6 bind4[/"year-from-dateTime(?dates)"/] v6 --o bind4 bind4 --as--o v13 v5 --"wdt:P31"--> v8 bind7[/"min(?years)"/] v13 --o bind7 bind7 --as--o v13 bind8[/"'1^^xsd:integer'"/] bind8 --as--o v13 bind9[/"sample(?article_type_)"/] v8 --o bind9 bind9 --as--o v13 v13 --"rdfs:label"--> v13 end union0r <== or ==> union0l end v5 --"wdt:P921"--> a3 a3 --"wdt:P1433"--> a4 a4 --"wdt:P279"--> c6 v5 --"wdt:P577"--> v6 bind10[/"year-from-dateTime(?dates)"/] v6 --o bind10 bind10 --as--o v13 v5 --"wdt:P31"--> v8 bind13[/"min(?years)"/] v13 --o bind13 bind13 --as--o v13 bind14[/"'1^^xsd:integer'"/] bind14 --as--o v13 bind15[/"sample(?article_type_)"/] v8 --o bind15 bind15 --as--o v13 bind17[/"min(?year_)"/] v13 --o bind17 bind17 --as--o v13 bind18[/"year-from-dateTime(NOW())"/] bind18 --as--o v13 bind20[/"str(numeric-floor(?year_ / '10^^xsd:integer'))"/] v13 --o bind20 bind20 --as--o v13 bind21[/"count(?work)"/] v5 --o bind21 bind21 --as--o v14