sparql-examples

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

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

088

rq turtle/ttl

Event aspect: related events 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 wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q133457282>

SELECT
  ?score ?event ?eventLabel ?eventDescription
  ?example_person ?example_personLabel
WHERE {
  { 
    SELECT
      (COUNT(DISTINCT ?person) AS ?score) ?event
      (SAMPLE(?person) AS ?example_person)
    WHERE {
      ?person ^wdt:P823 | ^wdt:P664 | wdt:P1344 | ^wdt:P710 | (^wdt:P98 / wdt:P4745) | (^wdt:P50 / wdt:P1433 / wdt:P4745 ) | ^wdt:P5804 target: , ?event .
      FILTER (?event != target:)
    }
    GROUP BY ?event
    ORDER BY DESC(?score)
    LIMIT 200
  } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
ORDER BY DESC(?score)

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?event"):::projected 
  v4("?example_person"):::projected 
  v3("?person")
  v4("?score"):::projected 
  a1((" "))
  a2((" "))
  a3((" "))
  c1([http://www.wikidata.org/entity/Q133457282]):::iri 
  c14(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal 
  c12([http://www.bigdata.com/rdf#serviceParam]):::iri 
  f0[["?event != http://www.wikidata.org/entity/Q133457282"]]
  f0 --> v2
  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;
              c1 --"p:direct/P5804"-->  v3
              v2 --"p:direct/P5804"-->  v3
            end
            subgraph union5r[" "]
              style union5r fill:#abf,stroke-dasharray: 3 3;
              a2 --"p:direct/P50"-->  v3
              a2 --"p:direct/P1433"-->  a3
              a3 --"p:direct/P4745"-->  c1
              a2 --"p:direct/P50"-->  v3
              a2 --"p:direct/P1433"-->  a3
              a3 --"p:direct/P4745"-->  v2
            end
            union5r <== or ==> union5l
            end
          end
          subgraph union4r[" "]
            style union4r fill:#abf,stroke-dasharray: 3 3;
            a1 --"p:direct/P98"-->  v3
            a1 --"p:direct/P4745"-->  c1
            a1 --"p:direct/P98"-->  v3
            a1 --"p:direct/P4745"-->  v2
          end
          union4r <== or ==> union4l
          end
        end
        subgraph union3r[" "]
          style union3r fill:#abf,stroke-dasharray: 3 3;
          c1 --"p:direct/P710"-->  v3
          v2 --"p:direct/P710"-->  v3
        end
        union3r <== or ==> union3l
        end
      end
      subgraph union2r[" "]
        style union2r fill:#abf,stroke-dasharray: 3 3;
        v3 --"p:direct/P1344"-->  c1
        v3 --"p:direct/P1344"-->  v2
      end
      union2r <== or ==> union2l
      end
    end
    subgraph union1r[" "]
      style union1r fill:#abf,stroke-dasharray: 3 3;
      c1 --"p:direct/P664"-->  v3
      v2 --"p:direct/P664"-->  v3
    end
    union1r <== or ==> union1l
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    c1 --"p:direct/P823"-->  v3
    v2 --"p:direct/P823"-->  v3
  end
  union0r <== or ==> union0l
  end
  bind3[/"count(?person)"/]
  v3 --o bind3
  bind3 --as--o v4
  bind4[/"sample(?person)"/]
  v3 --o bind4
  bind4 --as--o v4
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c12 --"wikibase:language"-->  c14
  end