query-854b7019bd242d22f726dd52abaadda7

rq turtle/ttl

Q106471#P569

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wds: <http://www.wikidata.org/entity/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?reference ?referenceItem ?referenceItemLabel ?quality_step_c
WHERE 
{
  wds:q106471-515C1587-101A-48A6-AF11-61EE615B90FE prov:wasDerivedFrom ?reference. # the statement is https://www.wikidata.org/wiki/Q106471#P569
  ?reference pr:P248|pr:P143 ?referenceItem.
  BIND(0 AS ?quality_step_a)
  BIND(IF(EXISTS{?reference pr:P143 [].},?quality_step_a - 1,?quality_step_a) AS ?quality_step_b) # the reference has a property P143 (imported from Wikimedia project)
  BIND(IF(EXISTS{?referenceItem wdt:P629 [].},?quality_step_b + 1,?quality_step_b) AS ?quality_step_c) # the referenceItem has a property P629 (edition or translation of)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?quality_step_c)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?quality_step_a") v5("?quality_step_b") v6("?quality_step_c"):::projected v2("?reference"):::projected v3("?referenceItem"):::projected c1(["wds:q106471-515C1587-101A-48A6-AF11-61EE615B90FE"]):::iri c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal c1 --"prov:wasDerivedFrom"--> v2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"pr:P143"--> v3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"pr:P248"--> v3 end union0r <== or ==> union0l end bind0[/"'0^^xsd:integer'"/] bind0 --as--o v4 v2 --"pr:P143"--> null bind1[/"if( ,?quality_step_a - '1^^xsd:integer',?quality_step_a)"/] subgraph bind1e0["Exists Clause"] e0v1 --"pr:P143"--> e0a1 e0v1("?reference"):::projected e0a1((" ")):::projected end bind1--EXISTS--> bind1e0 v2 --o bind1 c4 --o bind1 null --o bind1 v4 --o bind1 bind1 --as--o v5 v3 --"wdt:P629"--> null bind2[/"if( ,?quality_step_b + '1^^xsd:integer',?quality_step_b)"/] subgraph bind2e1["Exists Clause"] e1v1 --"wdt:P629"--> e1a1 e1v1("?referenceItem"):::projected e1a1((" ")):::projected end bind2--EXISTS--> bind2e1 v3 --o bind2 null --o bind2 null --o bind2 v5 --o bind2 bind2 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end