query-4663ff0046ec8ffd5393c44a12e1c96b
: How do you get the number 4462? If I modify the query to count the images I get 6326 images found at Wikidata and 6317 files found at WCQS. The small difference of 9 can be images without structured data or new images since the last weekly update of WCQS: Vojtěch Dostál@
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?username ?file
WHERE
{
{
SELECT ?file
WHERE
{
{
SELECT ?item ?image ?filename ?contentUrl
WHERE
{
SERVICE <https://query.wikidata.org/sparql>
{
?item wdt:P31 wd:Q5153359 .
?item wdt:P18 ?image .
}
BIND (REPLACE(wikibase:decodeUri(SUBSTR(STR(?image), 52)), " ", "_") AS ?filename)
BIND (REPLACE(SUBSTR(STR(?image), 52), "%20", "_") AS ?filenameUnencoded)
BIND (MD5(?filename) AS ?MD5)
BIND (URI(CONCAT("https://upload.wikimedia.org/wikipedia/commons/", SUBSTR(?MD5, 1, 1), "/", SUBSTR(?MD5, 1, 2), "/", ?filenameUnencoded)) As ?contentUrl)
}
} ?file schema:contentUrl ?contentUrl .
}
} ?file p:P170 / pq:P4174 ?username .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?MD5")
v6("?contentUrl")
v7("?file"):::projected
v3("?filename")
v4("?filenameUnencoded")
v2("?image")
v1("?item")
v8("?username"):::projected
a1((" "))
c3(["wd:Q5153359"]):::iri
subgraph s1["https://query.wikidata.org/sparql"]
style s1 stroke-width:4px;
v1 --"p:direct/P31"--> c3
v1 --"p:direct/P18"--> v2
end
bind0[/"replace(http://wikiba.se/ontology#decodeUri(substring(str(?image),'52^^xsd:integer')),' ','_')"/]
v2 --o bind0
bind0 --as--o v3
bind1[/"replace(substring(str(?image),'52^^xsd:integer'),'%20','_')"/]
v2 --o bind1
bind1 --as--o v4
bind2[/"MD5(?filename)"/]
v3 --o bind2
bind2 --as--o v5
bind3[/"concat('https://upload.wikimedia.org/wikipedia/commons/',substring(?MD5,'1^^xsd:integer','1^^xsd:integer'),'/',substring(?MD5,'1^^xsd:integer','2^^xsd:integer'),'/',?filenameUnencoded)"/]
v5 --o bind3
v4 --o bind3
bind3 --as--o v6
v7 --"schema:contentUrl"--> v6
v7 --"p:P170"--> a1
a1 --"p:qualifier/P4174"--> v8