query-761f9d11ec39a323ae383c9a42ae3b0e

rq turtle/ttl

Property labels for all properties connected to an itemI am trying to get all information which is required to display a wikidata page for a given item, and to link back to all relevant bits of the actual Wikidata page. So given say Q1, I want to get: All the item labels involved in the display. If say Q2 appeared as an object in Q1 I would want to get "Earth" as its label. All the property labels for each property involved in the display. So for P31 for example I want to get "instance of" as the 'label'. Links to each triple in which Q1 is the subject All connections Q1 makes/all the triples in which Q1 is the subjectI have created this query:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:ImageGrid
  SELECT ?property ?propertyLabel ?statementLink ?simplevalue ?simplevalueLabel ?simplevalueLink ?propdirect ?propdirectLabel
  WHERE
  {
    wd:Q1 ?property ?statementLink . 
    ?statementLink ?simplevalueLink ?simplevalue .
    wd:Q1 ?propdirect ?simplevalue.

    FILTER(STRSTARTS(STR(?propdirect), "http://www.wikidata.org/prop/direct/"))
    FILTER(STRSTARTS(STR(?property), "http://www.wikidata.org/prop/P")) 
    FILTER(STRSTARTS(STR(?simplevalueLink), "http://www.wikidata.org/prop/statement/"))
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
  }

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?propdirect"):::projected v2("?property"):::projected v5("?simplevalue"):::projected v1("?simplevalueLink"):::projected v4("?statementLink"):::projected c6(["bd:serviceParam"]):::iri c4(["wd:Q1"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["starts-with(str(?simplevalueLink),'http://www.wikidata.org/prop/statement/')"]] f0 --> v1 f1[["starts-with(str(?property),'http://www.wikidata.org/prop/P')"]] f1 --> v2 f2[["starts-with(str(?propdirect),'http://www.wikidata.org/prop/direct/')"]] f2 --> v3 c4 -->v2--> v4 v4 -->v1--> v5 c4 -->v3--> v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end