sparql-examples

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

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

081

rq turtle/ttl

Event aspect: data

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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
  ?description ?descriptionLabel ?descriptionUrl

  ?value ?valueLabel ?valueUrl

WHERE {
  {
    BIND(1 AS ?order)
    BIND("Event series" AS ?description)
    BIND("/event-series" AS ?descriptionUrl)
    target: wdt:P179 ?value .
    BIND(CONCAT("/event-series/", SUBSTR(STR(?value), 32)) AS ?valueUrl)
  }
  UNION
  {
    BIND(2 AS ?order)
    BIND("Short name" AS ?description)
    target: wdt:P1813 ?value .
  }
  UNION
  {
    BIND(5 AS ?order)
    BIND(wd:Q34770 AS ?description)
    BIND("/language" AS ?descriptionUrl)
    
    target: wdt:P2936 ?value .
    BIND(CONCAT("/language/", SUBSTR(STR(?value), 32)) AS ?valueUrl)
  }
  UNION
  {
    SELECT
      (10 AS ?order)
      ("Organizers" AS ?description)
      (GROUP_CONCAT(?value_; separator=", ") AS ?value)
      (CONCAT("/authors/", GROUP_CONCAT(?q; separator=",")) AS ?valueUrl)      
    {
      BIND(1 AS ?dummy)
      target: wdt:P664 ?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_)
    }
    GROUP BY ?dummy
  }
  UNION
  {
    BIND(20 AS ?order)
    BIND("Number of participants" AS ?description)
    
    target: wdt:P1132 ?value .
  }
  UNION
  {
    # number of submissions
    BIND(21 AS ?order)
    BIND("number of submissions"  AS ?description)
    
    target: p:P12655 ?value_statement .
    ?value_statement ps:P12655 ?submissions.
    OPTIONAL {
      ?value_statement  pq:P518 / rdfs:label ?track .
      FILTER (LANG(?track) = "en")
    }
    BIND(IF(BOUND(?track), CONCAT(STR(?submissions), " (", ?track, ")"), STR(?submissions)) AS ?value)
  }
  UNION
  {
    # number of accepted contributions
    BIND(22 AS ?order)
    BIND("number of accepted contributions"  AS ?description)
    
    target: p:P12649 ?value_statement .
    ?value_statement ps:P12649 ?accepted .
    OPTIONAL {
      ?value_statement  pq:P518 / rdfs:label ?track .
      FILTER (LANG(?track) = "en")
    }
    BIND(IF(BOUND(?track), CONCAT(STR(?accepted), " (", ?track, ")"), STR(?accepted)) AS ?value)
  }
  UNION
  {
    BIND(23 AS ?order)
    BIND("Acceptance&nbsp;rate" AS ?description)
    
    target: p:P5822 ?value_statement .
    ?value_statement ps:P5822 ?acceptance_rate .
    OPTIONAL {
      ?value_statement  pq:P518 / rdfs:label ?track .
      FILTER (LANG(?track) = "en")
    }
    BIND(IF(BOUND(?track), CONCAT(STR(?acceptance_rate * 100), " % (", ?track, ")"), CONCAT(STR(?acceptance_rate * 100), " %")) AS ?value)
  }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
} 
ORDER BY ?order

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v11("?_anon_d5635a4148474aba9b1ec2d6f2e48935736")
  v16("?acceptance_rate")
  v15("?accepted")
  v16("?description"):::projected 
  v6("?descriptionUrl"):::projected 
  v7("?dummy")
  v8("?iri")
  v16("?order")
  v9("?q")
  v14("?submissions")
  v12("?track")
  v17("?value"):::projected 
  v12("?valueUrl"):::projected 
  v10("?value_")
  v13("?value_statement")
  v6("?value_string")
  a1((" "))
  a2((" "))
  a3((" "))
  c1(["wd:Q133457282"]):::iri 
  c19(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal 
  c17([http://www.bigdata.com/rdf#serviceParam]):::iri 
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    subgraph union1[" Union "]
    subgraph union1l[" "]
      style union1l fill:#abf,stroke-dasharray: 3 3;
      subgraph union2[" Union "]
      subgraph union2l[" "]
        style union2l fill:#abf,stroke-dasharray: 3 3;
        subgraph union3[" Union "]
        subgraph union3l[" "]
          style union3l fill:#abf,stroke-dasharray: 3 3;
          subgraph union4[" Union "]
          subgraph union4l[" "]
            style union4l fill:#abf,stroke-dasharray: 3 3;
            subgraph union5[" Union "]
            subgraph union5l[" "]
              style union5l fill:#abf,stroke-dasharray: 3 3;
              subgraph union6[" Union "]
              subgraph union6l[" "]
                style union6l fill:#abf,stroke-dasharray: 3 3;
                bind0[/"'23^^xsd:integer'"/]
                bind0 --as--o v16
                bind1[/"'Acceptance&nbsp;rate'"/]
                bind1 --as--o v16
                c1 --"p:P5822"-->  v13
                v13 --"p:statement/P5822"-->  v16
                subgraph optional0["(optional)"]
                style optional0 fill:#bbf,stroke-dasharray: 5 5;
                  v13 -."p:qualifier/P518".->  a3
                  a3 --"rdfs:label"-->  v12
                end
                bind2[/"if(bound(?track),concat(str(?acceptance_rate * '100^^xsd:integer'),' % (',?track,')'),concat(str(?acceptance_rate * '100^^xsd:integer'),' %'))"/]
                v12 --o bind2
                v16 --o bind2
                bind2 --as--o v17
              end
              subgraph union6r[" "]
                style union6r fill:#abf,stroke-dasharray: 3 3;
                bind3[/"'22^^xsd:integer'"/]
                bind3 --as--o v16
                bind4[/"'number of accepted contributions'"/]
                bind4 --as--o v16
                c1 --"p:P12649"-->  v13
                v13 --"p:statement/P12649"-->  v15
                subgraph optional1["(optional)"]
                style optional1 fill:#bbf,stroke-dasharray: 5 5;
                  v13 -."p:qualifier/P518".->  a2
                  a2 --"rdfs:label"-->  v12
                end
                bind5[/"if(bound(?track),concat(str(?accepted),' (',?track,')'),str(?accepted))"/]
                v12 --o bind5
                v15 --o bind5
                bind5 --as--o v17
              end
              union6r <== or ==> union6l
              end
            end
            subgraph union5r[" "]
              style union5r fill:#abf,stroke-dasharray: 3 3;
              bind6[/"'21^^xsd:integer'"/]
              bind6 --as--o v16
              bind7[/"'number of submissions'"/]
              bind7 --as--o v16
              c1 --"p:P12655"-->  v13
              v13 --"p:statement/P12655"-->  v14
              subgraph optional2["(optional)"]
              style optional2 fill:#bbf,stroke-dasharray: 5 5;
                v13 -."p:qualifier/P518".->  a1
                a1 --"rdfs:label"-->  v12
              end
              bind8[/"if(bound(?track),concat(str(?submissions),' (',?track,')'),str(?submissions))"/]
              v12 --o bind8
              v14 --o bind8
              bind8 --as--o v17
            end
            union5r <== or ==> union5l
            end
          end
          subgraph union4r[" "]
            style union4r fill:#abf,stroke-dasharray: 3 3;
            bind9[/"'20^^xsd:integer'"/]
            bind9 --as--o v16
            bind10[/"'Number of participants'"/]
            bind10 --as--o v16
            c1 --"p:direct/P1132"-->  v17
          end
          union4r <== or ==> union4l
          end
        end
        subgraph union3r[" "]
          style union3r fill:#abf,stroke-dasharray: 3 3;
          f11[["?value_string = 'en'"]]
          f11 --> v6
          bind12[/"'1^^xsd:integer'"/]
          bind12 --as--o v7
          c1 --"p:direct/P664"-->  v8
          bind13[/"substring(str(?iri),'32^^xsd:integer')"/]
          v8 --o bind13
          bind13 --as--o v9
          v8 --"rdfs:label"-->  v6
          bind14[/"?value_string?q"/]
          v6 --o bind14
          v9 --o bind14
          bind14 --as--o v10
          bind17[/"?q"/]
          v9 --o bind17
          bind17 --as--o v11
          bind18[/"'10^^xsd:integer'"/]
          bind18 --as--o v16
          bind19[/"'Organizers'"/]
          bind19 --as--o v16
          bind20[/"?value_"/]
          v10 --o bind20
          bind20 --as--o v17
          bind21[/"concat('/authors/',)"/]
          null --o bind21
          bind21 --as--o v12
        end
        union3r <== or ==> union3l
        end
      end
      subgraph union2r[" "]
        style union2r fill:#abf,stroke-dasharray: 3 3;
        bind22[/"'5^^xsd:integer'"/]
        bind22 --as--o v16
        bind23[/"http://wikidata.org/entity/Q34770"/]
        bind23 --as--o v16
        bind24[/"'/language'"/]
        bind24 --as--o v6
        c1 --"p:direct/P2936"-->  v17
        bind25[/"concat('/language/',substring(str(?value),'32^^xsd:integer'))"/]
        v17 --o bind25
        bind25 --as--o v12
      end
      union2r <== or ==> union2l
      end
    end
    subgraph union1r[" "]
      style union1r fill:#abf,stroke-dasharray: 3 3;
      bind26[/"'2^^xsd:integer'"/]
      bind26 --as--o v16
      bind27[/"'Short name'"/]
      bind27 --as--o v16
      c1 --"p:direct/P1813"-->  v17
    end
    union1r <== or ==> union1l
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    bind28[/"'1^^xsd:integer'"/]
    bind28 --as--o v16
    bind29[/"'Event series'"/]
    bind29 --as--o v16
    bind30[/"'/event-series'"/]
    bind30 --as--o v6
    c1 --"p:direct/P179"-->  v17
    bind31[/"concat('/event-series/',substring(str(?value),'32^^xsd:integer'))"/]
    v17 --o bind31
    bind31 --as--o v12
  end
  union0r <== or ==> union0l
  end
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c17 --"wikibase:language"-->  c19
  end