query-d1d8f1c2e95c0dfe279d8b34f648b22a

rq turtle/ttl

Find English labels only, but if no label in English allow any languageI'm basically getting all the data on a wikidata page, to use it for a tool. At the moment, I use this query to get that data:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?p_property ?p_propertyLabel ?statementLink ?simplevalue ?simplevalueLabel 
WHERE
{
  wd:Q1065 ?property ?statementLink . 
  ?statementLink ?simplevalueLink ?simplevalue .
  wd:Q1065 ?propdirect ?simplevalue.
  wd:Q1065 rdfs:label ?item.


  #find property label (thanks to tagishsimon)
  ?p_property wikibase:claim ?property .

  #find only properties & values with the right namespace
  FILTER(STRSTARTS(STR(?propdirect), STR(wdt:)))
  FILTER(STRSTARTS(STR(?property), STR(p:))) 
  FILTER(STRSTARTS(STR(?simplevalueLink),  STR(ps:)))

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } # Helps get the label in your language, if not, then en language

  #only get English language item names
  FILTER(LANGMATCHES(LANG(?item), "en"))
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v7("?p_property"):::projected v4("?propdirect") v3("?property") v6("?simplevalue"):::projected v2("?simplevalueLink") v5("?statementLink"):::projected c9(["bd:serviceParam"]):::iri c5(["wd:Q1065"]):::iri c1(["en"]):::literal f0[["langmatch(?item,'en')"]] f0 --> v1 f1[["starts-with(str(?simplevalueLink),str('p:statement/'))"]] f1 --> v2 f2[["starts-with(str(?property),str('p:'))"]] f2 --> v3 f3[["starts-with(str(?propdirect),str('p:direct/'))"]] f3 --> v4 c5 -->v3--> v5 v5 -->v2--> v6 c5 -->v4--> v6 c5 --"rdfs:label"--> v1 v7 --"wikibase:claim"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c1 end