Diese Seite wird von derWeb-Schnittstelle des Abfragedienstes geparst, um den Abfrage-Beispieldialog zu füllen. Viele der Beispiele funktionieren auch intemplate:Wikidata list-Template-Aufrufen, die durch denListeriaBot geparst werden, was jedoch voraussetzt, dass die Feldvariable '?item ausgewählt ist.
HINWEIS: Du musst ein eingeloggter Benutzer sein, um diese Commons-SPARQL-Abfragen ausführen zu können.
HINWEIS: Alternativ kannst du die viel schnellereQLever Wikimedia Commons-Instanz verwenden, die keine Anmeldung erfordert, aber nur ab und zu aktualisiert wird. Die letzte Aktualisierung fand am 30. Mai 2023 statt.
Diese einfachen Queries helfen dabei,SPARQL und dasWikibase-RDF-Format zu verstehen.
#shows M-entities that depict Douglas AdamsSELECT?fileWHERE{?filewdt:P180wd:Q42.}
Der ImageGrid-Anzeigemodus sucht nach Datei-URLs der Form, die von Wikidata-Eigenschaften wieimage(P18) als Werte verwendet werden, um Dateien zu identifizieren, die angezeigt werden können.
Die Aussage zum Abrufen eines Bildes lautet?fileschema:url?image.
#defaultView:ImageGridselect?file?imagewhere{?filewdt:P180wd:Q42.?fileschema:url?image.}
Dateien mitdigital representation of(P6243) aufDavid(Q179900) gesetzt
# Digital depictions of "David" by Michelangelo# Note how you can use a semicolon to group triples that have the same subject.#defaultView:ImageGridselect?file?imagewhere{?filewdt:P6243wd:Q179900;schema:url?image.}
Dateien, die sichdirekt indieser Kategorie befinden. Siehe auch dieMWAPI-Dokumentation.
# Files in category "Spoken English Wikipedia"SELECT?memberWHERE{BIND("Category:Spoken English Wikipedia"AS?category).SERVICEwikibase:mwapi{bd:serviceParamwikibase:endpoint"commons.wikimedia.org";wikibase:api"Generator";mwapi:generator"categorymembers";mwapi:gcmtype"file";# if you leave out this line it also returns subcategories and templatesmwapi:gcmtitle?category;mwapi:gcmprop"title";mwapi:gcmlimit"max".?memberwikibase:apiOutputmwapi:title.}}
Anzahl der Dateien mitWikimedia VRTS ticket number(P6305) Anweisungen
SELECT(COUNT(?file)AS?count){?filewdt:P6305?value.}
digital representation of(P6243)-Anweisungen haben eine „Einzelwertbeschränkung“, oder mit anderen Worten, jede Datei kann eine digitale Darstellung nur eines Wikidata-Elements sein (verwendedepicts(P180), wenn das Bild mehr Objekte enthält). Die folgende Abfrage findet Verstöße gegen Einschränkungen.
SELECT?file(COUNT(?value)AS?count){?filewdt:P6243?value.}GROUP BY?fileHAVING(?count>1)ORDER BYDESC(?count)LIMIT100
#defaultView:ImageGridselect?file?image{?fileschema:contentUrl?url;schema:height100;schema:width100;schema:url?image.}limit2000
select?encoding(count(*)as?total){?fileschema:encodingFormat?encoding.}group by?encodingorder bydesc(?total)
#defaultView:ScatterChartselect*{?fileschema:height?h;schema:width?w.}limit10000
Weitere Stichprobe:https://w.wiki/55rr
# Show a map of images depicting bridges AND having a coordinate for their point of view#defaultView:Mapselect?file?pov_coords?imagewhere{?filewdt:P180wd:Q12280;wdt:P1259?pov_coords;schema:url?image.}
#Captions of files depicting rosesSELECT?file?fileLabelWHERE{?filewdt:P180wd:Q102231.SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".}}
#Wikidata items of files in Category:Artworks with structured data with redirected P6243 propertySELECTDISTINCT?capturedWith?capturedWithLabel(count(?file)as?counts)WITH{SELECT?file?titleWHERE{SERVICEwikibase:mwapi{bd:serviceParamwikibase:api"Generator".bd:serviceParamwikibase:endpoint"commons.wikimedia.org".bd:serviceParammwapi:gcmtitle"Category:Media from iNaturalist".bd:serviceParammwapi:generator"categorymembers".bd:serviceParammwapi:gcmtype"file".bd:serviceParammwapi:gcmlimit"max".?titlewikibase:apiOutputmwapi:title.?pageidwikibase:apiOutput"@pageid".}BIND(URI(CONCAT('https://commons.wikimedia.org/entity/M',?pageid))AS?file)}}AS%get_filesWHERE{INCLUDE%get_files?fileschema:url?url;wdt:P4082?capturedWith.SERVICE<https://query.wikidata.org/sparql>{?capturedWithrdfs:label?capturedWithLabel.FILTER(lang(?capturedWithLabel)="en")}}GROUP BY?capturedWith?capturedWithLabelORDER BYDESC(?counts)
WARNUNG: Der Optimierer für Blazegraph hat unerwünschte Wechselwirkungen mit föderierten Abfragen. Es wird daher empfohlen, den Optimierer komplett abzuschalten oder einen Hinweis hinzuzufügen, dass der föderierte Teil zuerst ausgeführt werden soll. Dies kann mithint:Queryhint:optimizer"None" oderhint:Priorhint:runFirsttrue gemacht werden. Weitere Informationen können in derWikidataCon-Präsentation aus 2017 gefunden werden.
# Most common values for "source of image" (P7482). Limited to a random sample of 100,000 images to avoid timeout.SELECT?count?source?source_labelWHERE{{SELECT(COUNT(DISTINCT(?file))AS?count)?sourceWHERE{servicebd:sample{?filewdt:P7482?source.bd:serviceParambd:sample.limit100000.bd:serviceParambd:sample.sampleType"RANDOM".}}GROUP BY?source}SERVICE<https://query.wikidata.org/sparql>{OPTIONAL{?sourcerdfs:label?source_labelFILTER(lang(?source_label)='en')}.}}ORDER BYDESC(?count)?source_label
https://w.wiki/55fFSELECT?count?fabrication_method?fabrication_method_label?exampleWHERE{{SELECT(COUNT(DISTINCT(?file))AS?count)?fabrication_method(SAMPLE(?file)AS?example)WHERE{?filewdt:P2079?fabrication_method.}GROUP BY?fabrication_method}SERVICE<https://query.wikidata.org/sparql>{OPTIONAL{?fabrication_methodrdfs:label?fabrication_method_labelFILTER(lang(?fabrication_method_label)='en')}.}}ORDER BYDESC(?count)
# Most common "expression, gesture or body pose" (P6022) qualifier values for "depicts" (P180)SELECT?count?value?value_label?exampleWITH{SELECT(COUNT(DISTINCT(?file))AS?count)?value(SAMPLE(?file)AS?example)WHERE{?filep:P180/pq:P6022?value.}GROUP BY?valueORDER BYDESC(?count)LIMIT2000}AS%valuesWHERE{INCLUDE%values.service<https://query.wikidata.org/sparql>{OPTIONAL{?valuerdfs:label?value_labelFILTER(lang(?value_label)='en')}.}}ORDER BYDESC(?count)?value_label
tinyurl.com/y53kzn83 ; nicht menschlich:tinyurl.com/y35b5w3l#defaultView:ImageGridprefixcommons:<http://commons.wikimedia.org/wiki/Special:FilePath/>select?colorName?imagewith{select?color(iri(replace(str(sample(?photo)),"^.*/",str(commons:)))as?image)where{[aschema:ImageObject]schema:contentUrl?photo;p:P180[ps:P180wd:Q102231;pq:P462?color].}group by?color}as%roseswhere{include%roses.service<https://query.wikidata.org/sparql>{servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?colorrdfs:label?colorName.}}}
# Show all files depicting roses, and subclasses thereof#defaultView:ImageGridselectdistinct?item?itemLabel?imagewith{select?item?itemLabelwhere{service<https://query.wikidata.org/sparql>{?itemwdt:P31/wdt:P279*wd:Q34687.# subclasses of rosesservicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?itemrdfs:label?itemLabel.}}}}as%wikidataItemswhere{include%wikidataItems.?filewdt:P180?item;schema:url?image.}limit1000
#defaultView:ImageGridselect?image?painting?paintingLabel?paintingDescription?thumbwith{select*{service<https://query.wikidata.org/sparql>{?paintingwdt:P170wd:Q5582;rdfs:label?paintingLabel;schema:description?paintingDescription.filter(lang(?paintingLabel)="en")filter(lang(?paintingDescription)="en")}}}as%paintingswhere{include%paintings.?imagewdt:P180?painting;schema:url?thumb.}
#500 images that have both a specific church building and redundantly depict "church building" (Q16970)select?item?church?churchLabel?churchDescription?thumbwith{select*{service<https://query.wikidata.org/sparql>{?churchwdt:P31wd:Q16970;rdfs:label?churchLabel;schema:description?churchDescription.filter(lang(?churchLabel)="en")filter(lang(?churchDescription)="en")}}}as%churchwhere{include%church.?itemwdt:P180?church.?itemwdt:P180wd:Q16970.}LIMIT500
#defaultView:ImageGrid{"hide":["?img2"]}#defaultView:ImageGrid{"hide":["?img2"]}select?articleLabel?articleDesc?article?img2?imgDescwith{select*{# SELECT all articles published in German magazine 'Die Gartenlaube'service<https://query.wikidata.org/sparql>{?articlewdt:P1433wd:Q655617;rdfs:label?articleLabel;schema:description?articleDesc.filter(lang(?articleLabel)="en")filter(lang(?articleDesc)="en")}}}as%itemswhere{include%items.# Select images published in any article.?filewdt:P1433?article;schema:url?img2.optional{?filerdfs:label?imgDesc.filter(lang(?desc)="de")}.}
# Images of objects located in Helsinki, together with authors of those objects and copyright status#defaultView:ImageGridselect?image?item?itemLabel?itemDescription?thumb(?p170Labelas?author)(YEAR(?p570)as?death)?copyright_statusLabelwith{select*{service<https://query.wikidata.org/sparql>{?itemwdt:P131*wd:Q1757.?itemwdt:P170?p170.OPTIONAL{?itemrdfs:label?itemLabelfilter(lang(?itemLabel)="en")}OPTIONAL{?itemschema:description?itemDescriptionfilter(lang(?itemDescription)="en")}OPTIONAL{?p170rdfs:label?p170Labelfilter(lang(?p170Label)="en")}OPTIONAL{?p170wdt:P570?p570}.OPTIONAL{?p170wdt:P7763?copyright_status.?copyright_statusrdfs:label?copyright_statusLabelfilter(lang(?copyright_statusLabel)="en")}}}}as%workswhere{include%works.?imagewdt:P180?item;schema:url?thumb.}
# Map of files participating in Wiki Loves Monuments in Sweden, color-coded by year of competition#defaultView:Mapselect?image?wlm?wlmLabel?username?coords?thumb?layerwith{select*{service<https://query.wikidata.org/sparql>{?wlmwdt:P179wd:Q105194463;rdfs:label?wlmLabel;filter(lang(?wlmLabel)="en")}}}as%itemswhere{include%items.?imagewdt:P1344?wlm.OPTIONAL{?imagewdt:P1259?coords}OPTIONAL{?image(p:P170/pq:P4174)?username.}?imageschema:contentUrl?url;schema:url?thumb.BIND(IF(?wlm=wd:Q105201214,"2011",IF(?wlm=wd:Q105201215,"2012",IF(?wlm=wd:Q105201216,"2013",IF(?wlm=wd:Q105201217,"2014",IF(?wlm=wd:Q105201218,"2015",IF(?wlm=wd:Q105201219,"2016",IF(?wlm=wd:Q105201220,"2017",IF(?wlm=wd:Q105201221,"2018",IF(?wlm=wd:Q105201222,"2019",IF(?wlm=wd:Q105201223,"2020",""))))))))))AS?layer).}
# Media files depicting (former) heads of state that are still alive#defaultView:ImageGridselectdistinct?file?image?leaderLabelwith{select?leader?leaderLabelwhere{service<https://query.wikidata.org/sparql>{?leaderwdt:P31wd:Q5;wdt:P39?posHeld.minus{?leaderwdt:P570[].}# Minus date of death, only living people?posHeldwdt:P31/wdt:P279*wd:Q48352.# Position held = subclass or instance of 'head of state'servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?leaderrdfs:label?leaderLabel.}}}}as%wikidataItemswhere{include%wikidataItems.?filewdt:P180?leader;schema:url?image.}
# Number of Met Museum artworks in Commons, sorted by departmentSELECT?dept?deptLabel?countWHERE{{# Use Wikidata federated query to generate curatorial departments of The MetSELECT?dept?deptLabelWHERE{SERVICE<https://query.wikidata.org/sparql>{?deptwdt:P31wd:Q61781831.# curatorial department?deptwdt:P749wd:Q160236.# parent org being MetSERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?deptrdfs:label?deptLabel.# Department labels}}}}{# Find files of The MetSELECT(COUNT(DISTINCT(?file))AS?count)?deptWHERE{?filewdt:P3634?metid.# Files with Met ID?filewdt:P195?dept.# Department}GROUP BY?dept}}ORDER BYDESC(?count)?dept
#defaultView:Mapselect?file?image?depictionLabel?coordwhere{?filewdt:P6243wd:Q2520345.?filewdt:P180?depiction.?fileschema:url?image.service<https://query.wikidata.org/sparql>{?depictionwdt:P625?coord.servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?depictionrdfs:label?depictionLabel.}}}
# Most common classes of the values of "depicts" (P180) on CommonsSELECT((?sum/40)AS?percent)?class?class_label?instance?instance_label?sampleWITH{SELECT(COUNT(DISTINCT(?file))AS?count)?value(SAMPLE(?file)AS?example)WHERE{servicebd:sample{?filewdt:P180?value.bd:serviceParambd:sample.limit4000.bd:serviceParambd:sample.sampleType"RANDOM".}}GROUP BY?valueORDER BYDESC(?count)# LIMIT 2000}AS%valuesWITH{SELECT(SUM(?count)AS?sum)?class(SAMPLE(?value)AS?instance)(SAMPLE(?example)AS?sample)WHERE{INCLUDE%values.service<https://query.wikidata.org/sparql>{?valuewdt:P31?class}}GROUP BY?class}AS%classesWHERE{INCLUDE%classes.service<https://query.wikidata.org/sparql>{OPTIONAL{?instancerdfs:label?instance_labelFILTER(lang(?instance_label)='en')}.OPTIONAL{?classrdfs:label?class_labelFILTER(lang(?class_label)='en')}.}}ORDER BYDESC(?sum)
#Get information of Europeana item using federated queryPREFIXdc:<http://purl.org/dc/elements/1.1/>PREFIXedm:<http://www.europeana.eu/schemas/edm/>PREFIXore:<http://www.openarchives.org/ore/terms/>SELECT*WHERE{BIND(<http://data.europeana.eu/proxy/provider/91622/raa_kmb_16000200042758>as?p854)SERVICE<http://sparql.europeana.eu/>{{?p854<http://purl.org/dc/terms/created>?created.?p854<http://purl.org/dc/elements/1.1/identifier>?identifier.?p854<http://purl.org/dc/elements/1.1/publisher>?publisher.?p854<http://purl.org/dc/elements/1.1/rights>?rights.?p854<http://purl.org/dc/elements/1.1/title>?title.?p854<http://purl.org/dc/elements/1.1/description>?description.}}}
# Find Commons category suggestions for a Commons file using subjects stored in Europeana# 1.) Read collection and identifier for M68435429 (File:Tervahovi_Oulu_1898_02.jpg)# 2.) Read subjects in Finnish of photo defined by identifier from Europeana# 3.) Translate subjects to YSO ontology using Finto-service.# 3.b) Note: Query is routed through Sophox.org, because there is no direct access from WCQS to Finto.# 4.) Translate YSO items to Wikidata items using Wikidata and read Commons categoriesSELECT*WITH{SELECT?mediafile?collection?identifier?europeana?subjectWHERE{# 1.) Read collection and identifier for M68435429 (File:Tervahovi_Oulu_1898_02.jpg)BIND(sdc:M68435429as?mediafile)?mediafilep:P195?collection_prop.?collection_propps:P195?collection.?collection_proppq:P217?identifier# 2.) Read subjects in Finnish of photo defined by identifier from EuropeanaSERVICE<http://sparql.europeana.eu/>{?europeana<http://purl.org/dc/elements/1.1/identifier>?identifier.?europeana<http://purl.org/dc/elements/1.1/subject>?subject.}}}AS%europeanaWHERE{INCLUDE%europeana.# 3.) Translate subjects to YSO ontology using Finto-service.# 3.b) Note: Query is routed through Sophox.org, because there is no direct access from WCQS to Finto.SERVICE<http://zbw.eu/beta/sparql/stw/query>{SERVICE<http://api.finto.fi/sparql>{?ysoskos:prefLabel?subject;skos:inScheme<http://www.yso.fi/onto/yso/>}}# 4.) Translate YSO items to Wikidata items using Wikidata and read Commons categoriesBIND(REPLACE(STR(?yso),"http://www.yso.fi/onto/yso/p","")as?yso_number)SERVICE<https://query.wikidata.org/sparql>{?wikidatawdt:P2347?yso_number.?wikidatawdt:P373?commonscat}}
# World map of files authored by Wikimedia Commons user 'Coyau'#defaultView:Mapselect?file?image?coordinates(?dateAS?layer)?filenamewhere{bind("Coyau"AS?username)?file(p:P170/pq:P4174)?username;schema:url?image;?p?coordinates.# any coordinate like wdt:P625,wdt:P1259,wdt:P9149filter(datatype(?coordinates)=geo:wktLiteral).# If this line is not here, the query will be very slowoptional{?filewdt:P571?date.}?fileschema:contentUrl?url.BIND(wikibase:decodeUri(CONCAT("File:",substr(str(?url),53)))AS?filename).}LIMIT10000
# Timeline of files authored by a Wikimedia Commons user#TEMPLATE={"template":"Timeline of files authored by ?username","variables":{"?username":{"query":" SELECT DISTINCT ?username WHERE { [] p:P170/pq:P4174 ?username .} LIMIT 100"} } }#defaultView:TimelineSELECT?file?dateWHERE{BIND("Coyau"AS?username)?file(p:P170/pq:P4174)?username;wdt:P571?date.}LIMIT1000
# Count of photos taken by equipment type by Wikimedia Commons user 'Grendelkhan'SELECT?count?camera?camera_labelWHERE{{SELECT(COUNT(DISTINCT(?file))AS?count)?cameraWHERE{bind("Grendelkhan"AS?username)?file(p:P170/pq:P4174)?username;wdt:P4082?camera.}GROUP BY?camera}SERVICE<https://query.wikidata.org/sparql>{OPTIONAL{?camerardfs:label?camera_labelFILTER(lang(?camera_label)='en')}.}}ORDER BYDESC(?count)?camera_label
# Count of files from a given Flickr account over time#TEMPLATE={"template":"Count of files from from Flickr user ID ?flickr_user_id","variables":{"?flickr_user_id":{"query":" SELECT DISTINCT ?flickr_user_id WHERE { [] p:P170/pq:P3267 ?flickr_user_id .} LIMIT 100"} } }#defaultView:BarChartSELECT?year(COUNT(?file)AS?count)WHERE{BIND("26634002@N08"as?flickr_user_id)?filep:P170?creator_stmt.?creator_stmtpq:P3267?flickr_user_id.?filewdt:P571?date.BIND(STR(YEAR(?date))AS?year)FILTER(BOUND(?year))}GROUP BY?year
select?file?file_date?camera?camera_datewith{select*{# SELECT all camera modelsservice<https://query.wikidata.org/sparql>{?camerawdt:P31wd:Q20741022;wdt:P571?camera_date.}}}as%cameraswhere{include%cameras.#select images taken with the camera?filewdt:P4082?camera;wdt:P571?file_date.FILTER(?file_date<?camera_date)}LIMIT1000
# Items that have a creator of "some value" which could be a q numberSELECT?item?username?qnumbWITH{SELECT?qnumb?usernameWHERE{SERVICE<https://query.wikidata.org/sparql>{SELECTDISTINCT?qnumb?usernameWHERE{?qnumbwdt:P31wd:Q5;wdt:P4174?username.}}}}AS%usersWHERE{INCLUDE%users?itemp:P170/pq:P4174?username.?itemwdt:P170?creatorValFILTER(wikibase:isSomeValue(?creatorVal))}LIMIT10000
Der Dienstwikibase:mwapi bietet die Möglichkeit, SPARQL-Abfragen mit Commons-Kategorien zu kombinieren. Leider können von diesem Dienst nur 10.000 Dateien zurückgegeben werden. Diese Anzahl kann jedoch erweitert werden, da wir steuern können, welche 10.000 durch Hinzufügen zusätzlicher Befehle wie
bd:serviceParam mwapi:gcmsort "timestamp" . bd:serviceParam mwapi:gcmdir "descending" .
Die WartungskategorieCategory:Artworks with structured data with redirected digital representation of property sammelt Dateien mit der Anweisungdigital representation of(P6243), wobei das durch diese Anweisung verknüpfte Wikidata-Item eine Weiterleitung zu einem anderen Wikidata-Item ist. Die folgende Abfrage zeigt die Dateinamen, die durch die P6243-Eigenschaft verknüpften Elemente und die Elemente an, zu denen sie umleiten. Beachte, dass die Kategorie häufig leer ist und die Weiterleitungen möglicherweise bereits korrigiert wurden.
SELECT?file?title?redirect_from?redirect_toWITH{SELECT?file?titleWHERE{SERVICEwikibase:mwapi{bd:serviceParamwikibase:api"Generator".bd:serviceParamwikibase:endpoint"commons.wikimedia.org".bd:serviceParammwapi:gcmtitle"Category:Artworks with structured data with redirected digital representation of property".bd:serviceParammwapi:generator"categorymembers".bd:serviceParammwapi:gcmtype"file".bd:serviceParammwapi:gcmlimit"max".?titlewikibase:apiOutputmwapi:title.?pageidwikibase:apiOutput"@pageid".}BIND(URI(CONCAT('https://commons.wikimedia.org/entity/M',?pageid))AS?file)}}AS%get_filesWHERE{INCLUDE%get_files?filewdt:P6243?redirect_from.SERVICE<https://query.wikidata.org/sparql>{?redirect_fromowl:sameAs?redirect_to.}}
SELECT?file?title?depicts?depicts_labelWITH{SELECT?file?titleWHERE{SERVICEwikibase:mwapi{bd:serviceParamwikibase:api"Generator".bd:serviceParamwikibase:endpoint"commons.wikimedia.org".bd:serviceParammwapi:gcmtitle"Category:Historia Naturalis van Rudolf II".bd:serviceParammwapi:generator"categorymembers".bd:serviceParammwapi:gcmtype"file".bd:serviceParammwapi:gcmlimit"max".?titlewikibase:apiOutputmwapi:title.?pageidwikibase:apiOutput"@pageid".}BIND(URI(CONCAT('https://commons.wikimedia.org/entity/M',?pageid))AS?file)}}AS%get_filesWHERE{INCLUDE%get_files?filewdt:P180?depicts.service<https://query.wikidata.org/sparql>{OPTIONAL{?depictsrdfs:label?depicts_labelFILTER(lang(?depicts_label)='nl')}}}
#defaultView:MapSELECT?file?title?image?coordsWITH{SELECT?file?titleWHERE{SERVICEwikibase:mwapi{bd:serviceParamwikibase:api"Generator".bd:serviceParamwikibase:endpoint"commons.wikimedia.org".bd:serviceParammwapi:gcmtitle"Category:River Ravensbourne".bd:serviceParammwapi:generator"categorymembers".bd:serviceParammwapi:gcmtype"file".bd:serviceParammwapi:gcmlimit"max".?titlewikibase:apiOutputmwapi:title.?pageidwikibase:apiOutput"@pageid".}BIND(URI(CONCAT('https://commons.wikimedia.org/entity/M',?pageid))AS?file)}}AS%get_filesWHERE{INCLUDE%get_filesOPTIONAL{?filewdt:P1259?coords}.# coords of POVOPTIONAL{?filewdt:P9149?coords}.# fallback: coords of depicted placeFILTER(bound(?coords)).?fileschema:url?image.}
Einige Abfragen untersuchen, wie bestimmte Eigenschaften verwendet werden
Wikidata-Items mit der größten Anzahl von Dateien in Commons, die über die Anweisungdigital representation of(P6243) mit ihnen verknüpft sind.
SELECT?count?item?item_label?commonscat_linkWITH{SELECT(COUNT(DISTINCT(?file))AS?count)?itemWHERE{?filewdt:P6243?item.}GROUP BY?itemORDER BYDESC(?count)LIMIT200}AS%itemsWHERE{INCLUDE%items.service<https://query.wikidata.org/sparql>{OPTIONAL{?itemrdfs:label?item_labelFILTER(lang(?item_label)='en')}.OPTIONAL{?itemwdt:P373?commonscat.BIND(IRI(CONCAT("https://commons.wikimedia.org/wiki/Category:",?commonscat))AS?commonscat_link).}}}ORDER BYDESC(?count)?item_label
Hinweis - beschränkt auf eine Stichprobe von 50.000 Dateien, obwohl wir (derzeit) 225124 Dateien mitdigital representation of(P6243)-Anweisungen haben, da 50.000 eine so große Zahl zu sein scheint, wie vom Verband an WDQS zur Analyse ohne Zeitüberschreitung gesendet werden kann
SELECT(COUNT(DISTINCT(?file))AS?count)?class?class_labelWITH{SELECT?file?itemWHERE{?filewdt:P6243?item.}LIMIT50000}AS%filesWHERE{INCLUDE%files.service<https://query.wikidata.org/sparql>{?itemwdt:P31?class.OPTIONAL{?classrdfs:label?class_labelFILTER(lang(?class_label)='en')}.}}GROUP BY?class?class_labelORDER BYDESC(?count)?class_label
# # Most frequent qualifier properties when "source of image" (P7482) = "file available on the internet" (Q74228490)# based on sample of 100,000 such imagesSELECT?count?qualifier?qualifier_label?example?example_value?example_value_labelWITH{SELECT?file?source_stmtWHERE{servicebd:sample{?source_stmtps:P7482wd:Q74228490.bd:serviceParambd:sample.limit100000.bd:serviceParambd:sample.sampleType"RANDOM".}?filep:P7482?source_stmt.}}AS%filesWITH{SELECT(COUNT(DISTINCT(?file))AS?count)?qualifier(SAMPLE(?file)AS?example)(SAMPLE(?value)AS?example_value)WHERE{INCLUDE%files.?filep:P7482?source_stmt.?source_stmt?qualifier?value.}GROUP BY?qualifierORDER BYDESC(?count)LIMIT200}AS%source_infoWHERE{INCLUDE%source_info.service<https://query.wikidata.org/sparql>{?qualifier^wikibase:qualifier?qual_item.OPTIONAL{?qual_itemrdfs:label?qualifier_labelFILTER(lang(?qualifier_label)='en')}.OPTIONAL{?example_valuerdfs:label?example_value_labelFILTER(lang(?example_value_label)='en')}.}}ORDER BYDESC(?count)
(basierend auf einer Stichprobe von 10.000 Bildern mit solchen Anbieterangaben)
# Most frequent providers of images when "source of image" (P7482) = "file available on the internet" (Q74228490)SELECT?count?provider?provider_label?exampleWITH{SELECT(COUNT(DISTINCT(?file))AS?count)?provider(SAMPLE(?file)AS?example)WHERE{servicebd:sample{?source_stmtps:P7482wd:Q74228490.bd:serviceParambd:sample.limit10000.bd:serviceParambd:sample.sampleType"RANDOM".}?filep:P7482?source_stmt.?source_stmtpq:P137?provider.}GROUP BY?providerORDER BYDESC(?count)LIMIT200}AS%source_infoWHERE{INCLUDE%source_info.service<https://query.wikidata.org/sparql>{OPTIONAL{?providerrdfs:label?provider_labelFILTER(lang(?provider_label)='en')}.}}ORDER BYDESC(?count)
(aus einer nicht zufälligen Stichprobe von 500.000 Bildern)
# Images with largest number of depicts values#defaultView:ImageGridSELECT?count?image(GROUP_CONCAT(?topicLabel;separator=' / ')AS?topicLabels)WITH{SELECT?fileWHERE{?fileawikibase:Mediainfo.}LIMIT500000}AS%filesWITH{SELECT?file?topicWHERE{INCLUDE%files.MINUS{?filep:P180/wikibase:rankwikibase:PreferredRank}.?filewdt:P180?topic.}}AS%file_topicsWITH{SELECT(COUNT(DISTINCT(?topic))AS?count)?fileWHERE{INCLUDE%file_topics.}GROUP BY?fileORDER BYDESC(?count)LIMIT200}AS%top_filesWITH{SELECT?count?file?topicWHERE{INCLUDE%file_topics.INCLUDE%top_files.}}AS%top_file_topicsWITH{SELECTDISTINCT?topicWHERE{INCLUDE%top_file_topics.}}AS%top_topicsWITH{SELECT?topic?topicLabelWHERE{INCLUDE%top_topics.service<https://query.wikidata.org/sparql>{servicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?topicrdfs:label?topicLabel.}}}}AS%topicLabelsWHERE{INCLUDE%top_file_topics.INCLUDE%topicLabels.?fileschema:contentUrl?url.bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/",wikibase:decodeUri(substr(str(?url),53))))AS?image)}GROUP BY?count?file?imageORDER BYDESC(?count)
Suche alle Dateien mit demselben Wert, die zweimal zu derselben Eigenschaft hinzugefügt wurden. In diesem Beispiel haben wir die Anweisungdepicts(P180) verwendet, sie kann jedoch auch mit anderen verwendet werden. Diese Abfrage läuft manchmal ab, aber das Entfernen von „DISTINCT“ behebt das Problem und gibt jedoch mehrere Zeilen pro Datei zurück
SELECTDISTINCT?file{?filep:P180?statement1.?filep:P180?statement2.?statement1ps:P180?value.?statement2ps:P180?value.FILTER(?statement1!=?statement2)}limit50
# Things depicted with cats#defaultView:ImageGridSELECT?count?depicted?depictedLabel?sampleImgWITH{SELECT?targetWHERE{SERVICE<https://query.wikidata.org/sparql>{{?targetwdt:P31?/wdt:P279*wd:Q146}## include specific sorts of cats and individual catsUNION{?targetwdt:P31?wd:Q43577}## and also breeds of cat}}}AS%targetsWITH{SELECT(COUNT(DISTINCT(?file))AS?count)?depicted(SAMPLE(?file)AS?sample)WHERE{INCLUDE%targets.?filep:P180?stmt.?stmtps:P180?target.# ?stmt wikibase:rank wikibase:PreferredRank . ## Make sure the cat is marked as prominent -- **commented out for now**?filep:P180?stmt2.FILTER(?stmt2!=?stmt).## now get another depicts statement?stmt2ps:P180?depicted.}GROUP BY?depicted}AS%thingsWITH{SELECT?count?depicted?sampleWHERE{INCLUDE%things.MINUS{## exclude anything that was an original targetSELECT(?targetAS?depicted)WHERE{INCLUDE%targets.}}}}AS%things1WHERE{INCLUDE%things1.SERVICE<https://query.wikidata.org/sparql>{SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?depictedrdfs:label?depictedLabel.}}?sampleschema:contentUrl?url;schema:url?sampleImg.}ORDER BYDESC(?count)
tinyurl.com/y35wjrz8 (die Auswahl ist jedes Mal anders, wenn die Abfrage geändert wird oder wenn sie sich nicht mehr im Cache befindet)#defaultView:Map{"hide":["?coor"]}# query by Jura1, 2020-11-12SELECT?fileLabel?fileDescription?image?coorWHERE{hint:Queryhint:optimizer"None".SERVICE<https://query.wikidata.org/sparql>{wd:Q43244wdt:P625?center}# Wikidata item with coordinatesSERVICEwikibase:around{?filewdt:P1259?coor.bd:serviceParamwikibase:center?center.bd:serviceParamwikibase:radius"1".# 1 kilometer around}?fileschema:contentUrl?url.bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/",wikibase:decodeUri(substr(str(?url),53))))AS?image)SERVICEwikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en"}}
#defaultView:ImageGridSELECT?img(concat(str(floor(?match*100/16)),"% similar")as?similarity)WITH{SELECT?item?hash{# The file we want to look for similar items to.?itemschema:contentUrl<https://upload.wikimedia.org/wikipedia/commons/c/cf/Digitoitu_alkuper%C3%A4isest%C3%A4_negatiivista._%28d2005_167_6_17%29_Suomen_valokuvataiteen_museo.jpg>.?itemwdt:P9310?hash.FILTER(strlen(?hash)=16).}}as%hashWHERE{INCLUDE%hash?relatedImgwdt:P9310?hash2.?relatedImgschema:url?imgFILTER(?relatedImg!=?item)FILTER(strlen(?hash2)=16).# This is far from perfect as it should be bit-wise not nibble-wiseBIND(SUBSTR(?hash,1,1)=SUBSTR(?hash2,1,1)AS?h1).BIND(SUBSTR(?hash,2,1)=SUBSTR(?hash2,2,1)AS?h2).BIND(SUBSTR(?hash,3,1)=SUBSTR(?hash2,3,1)AS?h3).BIND(SUBSTR(?hash,4,1)=SUBSTR(?hash2,4,1)AS?h4).BIND(SUBSTR(?hash,5,1)=SUBSTR(?hash2,5,1)AS?h5).BIND(SUBSTR(?hash,6,1)=SUBSTR(?hash2,6,1)AS?h6).BIND(SUBSTR(?hash,7,1)=SUBSTR(?hash2,7,1)AS?h7).BIND(SUBSTR(?hash,8,1)=SUBSTR(?hash2,8,1)AS?h8).BIND(SUBSTR(?hash,9,1)=SUBSTR(?hash2,9,1)AS?h9).BIND(SUBSTR(?hash,10,1)=SUBSTR(?hash2,10,1)AS?h10).BIND(SUBSTR(?hash,11,1)=SUBSTR(?hash2,11,1)AS?h11).BIND(SUBSTR(?hash,12,1)=SUBSTR(?hash2,12,1)AS?h12).BIND(SUBSTR(?hash,13,1)=SUBSTR(?hash2,13,1)AS?h13).BIND(SUBSTR(?hash,14,1)=SUBSTR(?hash2,14,1)AS?h14).BIND(SUBSTR(?hash,15,1)=SUBSTR(?hash2,15,1)AS?h15).BIND(SUBSTR(?hash,16,1)=SUBSTR(?hash2,16,1)AS?h16).BIND(xsd:integer(?h1)+xsd:integer(?h2)+xsd:integer(?h3)+xsd:integer(?h4)+xsd:integer(?h5)+xsd:integer(?h6)+xsd:integer(?h7)+xsd:integer(?h8)+xsd:integer(?h9)+xsd:integer(?h10)+xsd:integer(?h11)+xsd:integer(?h12)+xsd:integer(?h13)+xsd:integer(?h14)+xsd:integer(?h15)+xsd:integer(?h16)as?match)}ORDER BYDESC(?match)LIMIT50
#defaultView:ImageGridSELECT?file?imageWHERE{?filewdt:P180wd:Q7561;p:P571?When.FILTEREXISTS{?Whenps:P571"2009-01-01T00:00:00Z"^^xsd:dateTime}?fileschema:url?image.}
#shows files that depict athletics competitors and with the Valued Image assessment#defaultView:ImageGridSELECT?file?imageWITH{SELECT?itemWHERE{SERVICE<https://query.wikidata.org/sparql>{?itemwdt:P106wd:Q11513337.}}}AS%get_itemsWHERE{INCLUDE%get_items?filewdt:P180?item.?filewdt:P6731wd:Q63348040.# Commons valued image?fileschema:url?image.}
#shows files that depict Hummingbirds and with the Quality Image assessment#defaultView:ImageGridSELECT?file?imageWITH{SELECT?itemWHERE{SERVICE<https://query.wikidata.org/sparql>{?itemwdt:P171/wdt:P171*wd:Q43624.}}}AS%get_itemsWHERE{INCLUDE%get_items?filewdt:P180?item.?filewdt:P6731wd:Q63348069.# Commons quality image?fileschema:url?image.}
#shows files that depict arch bridges in Italy and with the Quality Image assessment#defaultView:ImageGridSELECT?file?imageWITH{SELECT?itemWHERE{SERVICE<https://query.wikidata.org/sparql>{?itemwdt:P31wd:Q158438.?itemwdt:P17wd:Q38.}}}AS%get_itemsWHERE{INCLUDE%get_items?filewdt:P180?item.?fileschema:url?image.?filewdt:P6731wd:Q63348069.}
#shows files that depict Lepidoptera, with the Featured Picture assessment, and taken with a Canon camera#defaultView:ImageGridSELECT?file?imageWITH{SELECT?itemWHERE{SERVICE<https://query.wikidata.org/sparql>{?itemwdt:P171/wdt:P171*wd:Q28319.}}}AS%get_itemsWHERE{INCLUDE%get_items?filewdt:P180?item.?fileschema:url?image.?filewdt:P6731wd:Q63348049.?filewdt:P4082?camera.SERVICE<https://query.wikidata.org/sparql>{?camerawdt:P1716wd:Q63554165.# brand = Canon}}
#most common predictates on Commons items that depict Douglas AdamsSELECT(COUNT(DISTINCT(CONCAT(str(?file),str(?value))))AS?count)?prop(SAMPLE(?file)AS?sample_file)(SAMPLE(?value)AS?sample_value)WHERE{?filewdt:P180wd:Q42.?file?prop?value.}GROUP BY?propORDER BYDESC(?count)
SELECTDISTINCT?prop?propLabelWHERE{?filewdt:P180wd:Q42;schema:contentUrl?contentURL;?p?o.SERVICE<https://query.wikidata.org/sparql>{?propwikibase:claim?p;rdfs:label?propLabel.FILTER(lang(?propLabel)="en")}}
Eine Reihe benannter Unterabfragen (z. B. die WITH-Blöcke) werden verwendet, um die Ausführungssequenz zu erzwingen - sieheWikidata für ein wenig mehr dazu.
#most common predictates on a sample of 5,000 Commons filesSELECT(COUNT(DISTINCT?file)AS?file_count)(COUNT(DISTINCT(CONCAT(str(?file),str(?val))))AS?stmt_count)?prop?prop_label(SAMPLE(?file)AS?sample_file)(SAMPLE(?val)AS?sample_val)WITH{SELECT?fileWHERE{servicebd:sample{?fileawikibase:Mediainfo.bd:serviceParambd:sample.limit5000.bd:serviceParambd:sample.sampleType"RANDOM".}}}AS%filesWITH{SELECT?file?prop?valWHERE{INCLUDE%files.?file?prop?val.}}AS%triplesWITH{SELECTDISTINCT?propWHERE{INCLUDE%triples.}}AS%propsWITH{SELECT?prop?prop_labelWHERE{INCLUDE%props.service<https://query.wikidata.org/sparql>{OPTIONAL{?prop^wikibase:directClaim?prop_item.?prop_itemrdfs:label?prop_labelFILTER(lang(?prop_label)='en').}OPTIONAL{?prop^wikibase:claim?prop_item.?prop_itemrdfs:label?prop_labelFILTER(lang(?prop_label)='en').}}}}AS%prop_labelsWHERE{INCLUDE%triples.INCLUDE%prop_labels.}GROUP BY?prop?prop_labelORDER BYDESC(?stmt_count)
tinyurl.com/yyuywxqm# Most common qualifiers used on "depicts" statementsSELECTDISTINCT?count?qual?qual_label?sample_file('depicts'AS?prop)?sample_stmt_value?sample_stmt_valueLabel(?qual_labelAS?qualLabel1)?sample_value?sample_valueLabelWITH{SELECT?qualWHERE{service<https://query.wikidata.org/sparql>{?propwikibase:qualifier?qual.}}}AS%qualsWITH{SELECT?stmt?qualWHERE{INCLUDE%quals.?stmt?qual[].?filep:P180?stmt.}LIMIT30000}AS%stmtsWITH{SELECT(COUNT(DISTINCT(?stmt))AS?count)?qual(SAMPLE(?stmt)AS?example_stmt)WHERE{INCLUDE%stmts.}GROUP BY?qual}AS%top_qualsWITH{SELECT?count?qual(SAMPLE(?example_file)AS?sample_file)(SAMPLE(?example_stmt_value)AS?sample_stmt_value)(SAMPLE(?example_value)AS?sample_value)WHERE{INCLUDE%top_quals.?example_stmt^p:P180?example_file.?example_stmtps:P180?example_stmt_value.?example_stmt?qual?example_value.}GROUP BY?count?qual}AS%resultsWHERE{INCLUDE%results.service<https://query.wikidata.org/sparql>{?qual^wikibase:qualifier?qual_itemservicewikibase:label{bd:serviceParamwikibase:language"[AUTO_LANGUAGE],en".?qual_itemrdfs:label?qual_label.?sample_stmt_valuerdfs:label?sample_stmt_valueLabel.?sample_valuerdfs:label?sample_valueLabel.}}}ORDER BYDESC(?count)
# most common property + qualifier combinations, other than on "depicts" (P180) statementsSELECT?count?pred?pred_label?qual?qual_label?exampleWITH{SELECT?qualWHERE{service<https://query.wikidata.org/sparql>{?propwikibase:qualifier?qual.}}}AS%qualsWITH{SELECT?file?stmt?qual?predWHERE{INCLUDE%quals.?stmt?qual[].OPTIONAL{?f1p:P180?stmt}FILTER(!bound(?f1)).?file?pred?stmt.}LIMIT100000}AS%stmtsWITH{SELECT(COUNT(DISTINCT(?stmt))AS?count)?qual?pred(SAMPLE(?file)AS?example)WHERE{INCLUDE%stmts.}GROUP BY?qual?pred}AS%top_qualsWHERE{INCLUDE%top_quals.service<https://query.wikidata.org/sparql>{OPTIONAL{?pred^wikibase:claim?pred_item.?pred_itemrdfs:label?pred_labelFILTER(lang(?pred_label)='en').}OPTIONAL{?qual^wikibase:qualifier?qual_item.?qual_itemrdfs:label?qual_labelFILTER(lang(?qual_label)='en').}}}ORDER BYDESC(?count)
SELECT?depicts?count?depictsLabel_en?depictsLabel_esWITH{SELECT?depicts(count(?file)as?count)WHERE{SERVICEbd:slice{?filewdt:P180?depicts.bd:serviceParambd:slice.offset10000000.# Start at item number (not to be confused with QID)bd:serviceParambd:slice.limit3000000.# List this many items to prevent query timeout}}group by?depictshaving(?count>10&&?count<4000000)}AS%IWHERE{INCLUDE%ISERVICE<https://query.wikidata.org/sparql>{filternot exists{?depictsrdfs:label?depictsLabel_esFILTER(lang(?depictsLabel_es)='es')}OPTIONAL{?depictsrdfs:label?depictsLabel_enFILTER(lang(?depictsLabel_en)='en')}}}order bydesc(?count)
Hier ist eine SPARQL-Abfrage zur Suche nach Met-Bildern mit einer bestimmten Darstellungsanweisung und zum Löschen dieser Anweisungen mithilfe von Quickstatements. Mit dieser Methode kann man eine Massensuche und -löschung durchführen, ohne dass man lernen muss, wie man einen Bot codiert oder programmiert.
Begründung: Es gibt einige P180/depiction-Aussagen mit geringem Vertrauen, die entfernt werden müssen, also suche nach diesen Aussagen mit einem spezifischen Qualifier „stated in“ „Met tagging initiative“ und mit einer Referenzaussage. Erzeuge dann eine Liste von Quickstatement-Direktiven, die wir mit Hilfe von SPARQL-Stringfunktionen direkt inQuickstatements kopieren/einfügen können. Beispiel:
Tipp: Wenn du Quickstatements für Commons verwendest, stelle sicher, dass du „Create new command batch for:Commons [nur Batch-Modus!]“ auswählst, da es standardmäßig auf Wikidata funktioniert.
Eine nützliche Referenz für String-Funktionen steht unter:https://docs.cambridgesemantics.com/anzograph/v2.5/userdoc/string-functions.htm
SELECTDISTINCT?quickstatementWHERE{# Wikidata items of P180 terms we want to removeVALUES?exclude{wd:Q467wd:Q8441}?filewdt:P3634?metid.?filep:P180?fullstatement.?fullstatementps:P180?exclude.# All depictions w/ determination method Met tagging initiative,# and a specific reference statement.# This avoid deleting a depiction statement that might have been# added by another method (by hand, other source, etc)?fullstatementps:P180[];pq:P459wd:Q106429444;prov:wasDerivedFrom?ref.?refpr:P248?statedin.# Met tagging initiative?refpr:P854?refurl.# Some type of URL, typically https://collectionapi.metmuseum.org/public/collection/v1/objects/...# ?file schema:url ?image.# Want to construct a Quickstatement to remove this exact claim/statementBIND(REPLACE(STR(?file),"https://commons.wikimedia.org/entity/","")as?mid)BIND(REPLACE(STR(?fullstatement),"https://commons.wikimedia.org/entity/statement/","")as?statement)BIND(STRAFTER(?statement,"-")as?statementdetail)BIND(CONCAT("-STATEMENT","|",?mid,"$",?statementdetail)as?quickstatement)}