Commons:SPARQL query service/queries/examples

This page is a translated version of a page Commons:SPARQL query service/queries/examples and the translation is 100% complete. Changes to the translation template, respectively the source language can be submitted through Commons:SPARQL query service/queries/examples and have to be approved by a translation administrator.

Diese Seite wird von der Web-Schnittstelle des Abfragedienstes geparst, um den Abfrage-Beispieldialog zu füllen. Viele der Beispiele funktionieren auch in template:Wikidata list-Template-Aufrufen, die durch den ListeriaBot 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 schnellere QLever Wikimedia Commons-Instanz verwenden, die keine Anmeldung erfordert, aber nur ab und zu aktualisiert wird. Die letzte Aktualisierung fand am 30. Mai 2023 statt.

Einfache Abfragen

Diese einfachen Queries helfen dabei, SPARQL und das Wikibase-RDF-Format zu verstehen.

Darstellungen von Douglas Adams

#shows M-entities that depict Douglas Adams
SELECT ?file WHERE {
  ?file wdt:P180 wd:Q42 .
}

Try it!

Darstellungen von Douglas Adams als Bildraster

Der ImageGrid-Anzeigemodus sucht nach Datei-URLs der Form, die von Wikidata-Eigenschaften wie image (P18) als Werte verwendet werden, um Dateien zu identifizieren, die angezeigt werden können.

Die Aussage zum Abrufen eines Bildes lautet ?file schema:url ?image.

#defaultView:ImageGrid
select ?file ?image where {
  ?file wdt:P180 wd:Q42.
  ?file schema:url ?image.
}

Try it!

Digitale Darstellungen des „David“ von Michelangelo

Dateien mit digital representation of (P6243) auf David (Q179900) gesetzt

# Digital depictions of "David" by Michelangelo
# Note how you can use a semicolon to group triples that have the same subject.
#defaultView:ImageGrid
select ?file ?image where {
  ?file wdt:P6243 wd:Q179900;
        schema:url ?image.
}

Try it!

Anzahl der Dateien mit der Anweisung „Wikimedia OTRS-Ticketnummer“

Anzahl der Dateien mit Wikimedia VRTS ticket number (P6305) Anweisungen

SELECT (COUNT(?file) AS ?count)  {
  ?file wdt:P6305 ?value .
}

Try it!

Dateien mit mehreren „Digitale Darstellungen von“-Anweisungen

digital representation of (P6243)-Anweisungen haben eine „Einzelwertbeschränkung“, oder mit anderen Worten, jede Datei kann eine digitale Darstellung nur eines Wikidata-Elements sein (verwende depicts (P180), wenn das Bild mehr Objekte enthält). Die folgende Abfrage findet Verstöße gegen Einschränkungen.

SELECT ?file (COUNT(?value) AS ?count)  {
  ?file wdt:P6243 ?value .
} 
GROUP BY ?file 
HAVING ( ?count > 1 ) 
ORDER BY DESC(?count)
LIMIT 100

Try it!

Bildraster mit Bildern, die genau 100 × 100 px groß sind

#defaultView:ImageGrid
select ?file ?image {
  ?file schema:contentUrl ?url;
        schema:height 100;
        schema:width  100;
        schema:url ?image.
} limit 2000

Try it!

Anzahl der Dateien nach Dateityp

select ?encoding (count(*) as ?total) {
  ?file schema:encodingFormat ?encoding .
} 
group by ?encoding 
order by desc(?total)

Try it!

Streudiagramm mit Höhe / Breite einer Stichprobe von 10.000 Bildern

#defaultView:ScatterChart
select * {
  ?file schema:height ?h ;
        schema:width ?w .
} limit 10000

Try it!

Weitere Stichprobe: https://w.wiki/55rr

Karte einiger Bilder mit dem Tag „zeigt“ (P180) = „Brücke“ (Q12280)

# Show a map of images depicting bridges AND having a coordinate for their point of view
#defaultView:Map
select ?file ?pov_coords ?image where {
  ?file wdt:P180 wd:Q12280;
        wdt:P1259 ?pov_coords;
        schema:url ?image.
}

Try it!

Bildunterschriften von Dateien mit Rosen

#Captions of files depicting roses
SELECT ?file ?fileLabel WHERE {
  ?file wdt:P180 wd:Q102231 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!


Kameras, die von Naturforschern mit iNaturalist zur Identifizierung von Arten verwendet werden

#Wikidata items of files in Category:Artworks with structured data with redirected P6243 property
SELECT DISTINCT ?capturedWith ?capturedWithLabel (count(?file) as ?counts)
WITH
{
  SELECT ?file ?title
  WHERE
  {
   SERVICE wikibase:mwapi
    {
      bd:serviceParam wikibase:api "Generator" .
      bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
      bd:serviceParam mwapi:gcmtitle "Category:Media from iNaturalist" .
      bd:serviceParam mwapi:generator "categorymembers" .
      bd:serviceParam mwapi:gcmtype "file" .
      bd:serviceParam mwapi:gcmlimit "max" .
      ?title wikibase:apiOutput mwapi:title .
      ?pageid wikibase:apiOutput "@pageid" .
    }
    
    BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
  }
} AS %get_files
WHERE
{
  INCLUDE %get_files
  ?file schema:url ?url ;
        wdt:P4082 ?capturedWith .
  SERVICE <https://query.wikidata.org/sparql> {
    ?capturedWith rdfs:label ?capturedWithLabel .
    FILTER (lang(?capturedWithLabel) = "en")
                  
  }
} 
GROUP BY ?capturedWith ?capturedWithLabel
ORDER BY DESC(?counts)

Try it!

Verwendung der Föderation

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 mit hint:Query hint:optimizer "None" oder hint:Prior hint:runFirst true gemacht werden. Weitere Informationen können in der WikidataCon-Präsentation aus 2017 gefunden werden.

Nach Labels und Beschreibungen von Wikidata-Items suchen

Häufigste Werte für „Bildquelle“ (P7482)

  • Diese Abfrage verwendet den Verbund, um Wikidata-Beschriftungen für Wikidata-Items zu finden, die im ersten Teil entdeckt wurden
# Most common values for "source of image" (P7482).  Limited to a random sample of 100,000 images to avoid timeout.
SELECT ?count ?source ?source_label
WHERE {
  { 
    SELECT (COUNT(DISTINCT(?file)) AS ?count) ?source WHERE {
      service bd:sample {
        ?file wdt:P7482 ?source . 
        bd:serviceParam bd:sample.limit 100000 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
      }
    } GROUP BY ?source
  } 
  SERVICE <https://query.wikidata.org/sparql> {
    OPTIONAL {?source rdfs:label ?source_label FILTER (lang(?source_label) = 'en') } .
  }
}
ORDER BY DESC(?count) ?source_label

Try it!

Die häufigsten Qualifikationswerte für „Ausdruck, Geste oder Körperhaltung“ (P6022) für „Darstellungen“ (P180)

# Most common "expression, gesture or body pose" (P6022) qualifier values for "depicts" (P180)
SELECT ?count ?value ?value_label ?example

WITH { 
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?value (SAMPLE(?file) AS ?example) WHERE {
     ?file p:P180/pq:P6022 ?value . 
  } GROUP BY ?value
  ORDER BY DESC(?count)
  LIMIT 2000           
} AS %values
 
WHERE {
  INCLUDE %values .
  service <https://query.wikidata.org/sparql> {
    OPTIONAL {?value rdfs:label ?value_label FILTER (lang(?value_label) = 'en') } .
  }
}
ORDER BY DESC(?count) ?value_label

Try it!

  • auf den Menschen beschränkt: tinyurl.com/y53kzn83 ; nicht menschlich: tinyurl.com/y35b5w3l

Farben von Rosen

  • Dies verwendet den Verbund zu WDQS, um die Beschriftungen der Farbelitems zu erhalten, welche die auf den Bildern abgebildeten Rosen haben.
#defaultView:ImageGrid

prefix commons: <http://commons.wikimedia.org/wiki/Special:FilePath/>

select ?colorName ?image with {
  select ?color (iri(replace(str(sample(?photo)), "^.*/", str(commons:))) as ?image) where {
    [a schema:ImageObject] schema:contentUrl ?photo;
                           p:P180 [
                             ps:P180 wd:Q102231;
                             pq:P462 ?color
                           ].
  }
  group by ?color
} as %roses where {
  include %roses.

  service <https://query.wikidata.org/sparql> {
    service wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
      ?color rdfs:label ?colorName.
    }
  }
}

Try it!

Abrufen einer Reihe von Wikidata-Items nach Interesse

Unterarten von Rosen

  • Dies verwendet den Verbund zu WDQS, um die Items der Unterklassen von Rosen zu erhalten
# Show all files depicting roses, and subclasses thereof
#defaultView:ImageGrid
select distinct ?item ?itemLabel ?image with {
  select ?item ?itemLabel where {
    service <https://query.wikidata.org/sparql> {
      ?item wdt:P31/wdt:P279* wd:Q34687. # subclasses of roses
      service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?item rdfs:label ?itemLabel . }
    }
  }
} as %wikidataItems where {
  include %wikidataItems .
  ?file wdt:P180 ?item;
        schema:url ?image.
} limit 1000

Try it!

Alle Bilder, die Kunstwerke von Van Gogh zeigen

  • Verwende den Verbund, um alle Wikidata-Items zu finden, die „Schöpfer“ (P170) als Vincent van Gogh (Q5582) haben, und finde dann alle Medienelemente, welche diese Bilder darstellen und diese in einem Raster anzuzeigen.
#defaultView:ImageGrid
select ?image ?painting ?paintingLabel ?paintingDescription ?thumb with {
  select * {
    service <https://query.wikidata.org/sparql> {
      ?painting wdt:P170 wd:Q5582;
                rdfs:label ?paintingLabel;
                schema:description ?paintingDescription.
      filter (lang(?paintingLabel) = "en")
      filter (lang(?paintingDescription) = "en")
    }
  } 
} as %paintings where {
  include %paintings. 
  ?image wdt:P180 ?painting;
         schema:url ?thumb.
}

Try it!

Erkenne die Darstellung einer bestimmten Kirche und des generischen „Kirchengebäudes“

  • Erkennen der Redundanz eines „abgebildeten“ Konzepts mit etwas Spezifischerem basierend auf Wikidata. Die Föderation wird verwendet, um alle Elemente abzurufen, die Instanzen des „Kirchenbaus“ sind.
#500 images that have both a specific church building and redundantly depict "church building" (Q16970)   
select ?item ?church ?churchLabel ?churchDescription ?thumb with {
  select * {
    service <https://query.wikidata.org/sparql> {
      ?church wdt:P31 wd:Q16970;
                rdfs:label ?churchLabel;
                schema:description ?churchDescription.
      filter (lang(?churchLabel) = "en")
      filter (lang(?churchDescription) = "en")
    }
  } 
} as %church where {
  include %church. 
  ?item wdt:P180 ?church.
  ?item wdt:P180 wd:Q16970.
}

LIMIT 500

Try it!

Illustration in der deutschen Zeitschrift 'Die Gartenlaube' im Wikidata-Verbund veröffentlicht

  • Hierbei wird der Verband verwendet, um Artikel published in (P1433) der deutschen Zeitschrift 'Die Gartenlaube' zusammen mit einigen Informationen zu diesen Artikeln zu finden.
    Nachdem man diesen Satz abgerufen hat, findet man Commons-Dateien mit den Commons-Aussagen, dass diese Artikel published in (P1433) waren
#defaultView:ImageGrid{"hide":["?img2"]}
#defaultView:ImageGrid{"hide":["?img2"]}
select ?articleLabel ?articleDesc ?article ?img2 ?imgDesc with {
  select * {
    # SELECT all articles published in German magazine 'Die Gartenlaube'
    service <https://query.wikidata.org/sparql> {
      ?article wdt:P1433 wd:Q655617;
               rdfs:label ?articleLabel;
               schema:description ?articleDesc.
      filter(lang(?articleLabel) = "en")
      filter(lang(?articleDesc) = "en")
    }
  }
} as %items where {
  include %items .
  # Select images published in any article.
  ?file wdt:P1433 ?article; 
        schema:url ?img2.
  
  optional {?file rdfs:label ?imgDesc. filter(lang(?desc) = "de") } .
}

Try it!

Bilder von Objekten, die sich in Helsinki befinden, zusammen mit den Urhebern dieser Objekte und dem Urheberrechtsstatus

# Images of objects located in Helsinki, together with authors of those objects and copyright status
#defaultView:ImageGrid
select ?image ?item ?itemLabel ?itemDescription ?thumb (?p170Label as ?author) (YEAR(?p570) as ?death) ?copyright_statusLabel with {
  select * {
    service <https://query.wikidata.org/sparql> {
      ?item wdt:P131* wd:Q1757 .            
      ?item wdt:P170 ?p170 .
      OPTIONAL { ?item rdfs:label ?itemLabel filter (lang(?itemLabel) = "en") }
      OPTIONAL { ?item schema:description ?itemDescription filter (lang(?itemDescription) = "en") }    
      OPTIONAL { ?p170 rdfs:label ?p170Label filter (lang(?p170Label) = "en") } 
      OPTIONAL { ?p170 wdt:P570 ?p570 } .
      OPTIONAL { ?p170 wdt:P7763 ?copyright_status. 
                 ?copyright_status rdfs:label ?copyright_statusLabel
                 filter (lang(?copyright_statusLabel) = "en")
               }
    }
  }
} as %works where {
  include %works.
  ?image wdt:P180 ?item;
         schema:url ?thumb.
}

Try it!

Karte der Dateien, die an Wiki Loves Monuments in Schweden teilnehmen, farbkodiert nach Jahr des Wettbewerbs

# Map of files participating in Wiki Loves Monuments in Sweden, color-coded by year of competition
#defaultView:Map
select ?image ?wlm ?wlmLabel ?username ?coords ?thumb ?layer 

with {
  select * {
    service <https://query.wikidata.org/sparql> {
      ?wlm wdt:P179 wd:Q105194463;
                rdfs:label ?wlmLabel;
      filter (lang(?wlmLabel) = "en")
    }
  } 
} as %items 

where {
  include %items. 
  ?image wdt:P1344 ?wlm.
  OPTIONAL {?image wdt:P1259 ?coords}
  OPTIONAL {?image (p:P170/pq:P4174) ?username.}

  ?image schema: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).
}

Try it!

Media files depicting (former) heads of state that are still alive

# Media files depicting (former) heads of state that are still alive
#defaultView:ImageGrid
select distinct ?file ?image ?leaderLabel with {
  select ?leader ?leaderLabel where {
    service <https://query.wikidata.org/sparql> {
      ?leader wdt:P31 wd:Q5;
            wdt:P39 ?posHeld. 
      minus { ?leader wdt:P570 []. } # Minus date of death, only living people
      ?posHeld wdt:P31/wdt:P279* wd:Q48352. # Position held = subclass or instance of 'head of state'
      service wikibase:label { 
        bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
        ?leader rdfs:label ?leaderLabel. 
      }
    }
  }
} as %wikidataItems where {
  include %wikidataItems .
  ?file wdt:P180 ?leader;
        schema:url ?image.
}

Try it!

Erstellung eines Berichts über die Kunstwerke des Met Museums nach Abteilung mit Hilfe einer Verbundabfrage

# Number of Met Museum artworks in Commons, sorted by department
SELECT ?dept ?deptLabel ?count 
WHERE {
  {
    # Use Wikidata federated query to generate curatorial departments of The Met
    SELECT ?dept ?deptLabel WHERE {  
      SERVICE <https://query.wikidata.org/sparql> {
        ?dept wdt:P31 wd:Q61781831 .  # curatorial department
        ?dept wdt:P749 wd:Q160236 .   # parent org being Met
        SERVICE wikibase:label {
          bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
          ?dept rdfs:label ?deptLabel .  # Department labels
        }
      }
    }
  }
  {
    # Find files of The Met
    SELECT (COUNT(DISTINCT(?file)) AS ?count) ?dept WHERE {
      ?file wdt:P3634 ?metid . # Files with Met ID
      ?file wdt:P195 ?dept .   # Department
    } GROUP BY ?dept
  }
}
ORDER BY DESC(?count) ?dept

Try it!

Föderation mit Wikidata zum Gruppieren, Analysieren oder Hinzufügen von Informationen zu Commons-Ergebnissen

Karte mit Abbildungen aus dem Atlas De Wit aus dem 17. Jahrhundert

#defaultView:Map
select ?file ?image ?depictionLabel ?coord where {
  ?file wdt:P6243 wd:Q2520345 .
  ?file wdt:P180 ?depiction .
  ?file schema:url ?image .
  service <https://query.wikidata.org/sparql> {
    ?depiction wdt:P625 ?coord.
    service wikibase:label {
        bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
        ?depiction rdfs:label ?depictionLabel .
    }
  }
}

Try it!

Häufigste wikidata-Klassen für Werte von „depicts“ (P180) auf Commons

# Most common classes of the values of "depicts" (P180) on Commons
SELECT ((?sum / 40) AS ?percent) ?class ?class_label ?instance ?instance_label ?sample

WITH { 
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?value (SAMPLE(?file) AS ?example) WHERE {
     service bd:sample {
       ?file wdt:P180 ?value . 
        bd:serviceParam bd:sample.limit 4000 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
     }  
  } GROUP BY ?value
  ORDER BY DESC(?count)
#  LIMIT 2000           
} AS %values
 
WITH {
  SELECT (SUM(?count) AS ?sum) ?class (SAMPLE(?value) AS ?instance) (SAMPLE(?example) AS ?sample) WHERE {
    INCLUDE %values .
    service <https://query.wikidata.org/sparql> {
         ?value wdt:P31 ?class
    }
  } GROUP BY ?class 
} AS %classes

WHERE {
  INCLUDE %classes . 
  service <https://query.wikidata.org/sparql> {
      OPTIONAL {?instance rdfs:label ?instance_label FILTER (lang(?instance_label) = 'en') } .
      OPTIONAL {?class rdfs:label ?class_label FILTER (lang(?class_label) = 'en') } .
  }
} 
ORDER BY DESC(?sum)

Try it!

Föderation mit externen Quellen

Erhalte Informationen zum Europeana-Artikel mithilfe einer Verbundabfrage

#Get information of Europeana item using federated query
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX ore: <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 .
     }
  }
}

Try it!

Lies die allgemeinen Kategorien für Europeana-Themen mithilfe einer Verbundabfrage

# 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 categories

SELECT * WITH {
  SELECT ?mediafile ?collection ?identifier ?europeana ?subject WHERE {
    
     # 1.) Read collection and identifier for M68435429 (File:Tervahovi_Oulu_1898_02.jpg)
     BIND(sdc:M68435429 as ?mediafile)     
     ?mediafile p:P195 ?collection_prop .
     ?collection_prop ps:P195 ?collection .
     ?collection_prop pq:P217 ?identifier
     
     # 2.) Read subjects in Finnish of photo defined by identifier from Europeana
     SERVICE <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 %europeana
WHERE {
  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> {
      ?yso skos:prefLabel ?subject ;
      skos:inScheme <http://www.yso.fi/onto/yso/>
    }
  } 
  # 4.) Translate YSO items to Wikidata items using Wikidata and read Commons categories
  BIND(REPLACE(STR(?yso), "http://www.yso.fi/onto/yso/p", "") as ?yso_number)
  SERVICE <https://query.wikidata.org/sparql>  {
    ?wikidata wdt:P2347 ?yso_number .
    ?wikidata wdt:P373 ?commonscat  
  }
}

Try it!

Erkunde Benutzer-Uploads

Weltkarte der Dateien, verfasst von Wikimedia Commons Benutzer „Coyau“

# World map of files authored by Wikimedia Commons user 'Coyau'
#defaultView:Map
select ?file ?image ?coordinates (?date AS ?layer) ?filename where {
  bind("Coyau" AS ?username)
  
  ?file (p:P170/pq:P4174) ?username;
        schema:url ?image;
        ?p ?coordinates. # any coordinate like wdt:P625,wdt:P1259,wdt:P9149
  
  filter(datatype(?coordinates) = geo:wktLiteral). # If this line is not here, the query will be very slow
  
  optional { ?file wdt:P571 ?date. }
  ?file schema:contentUrl ?url .
  BIND (wikibase:decodeUri(CONCAT("File:", substr(str(?url),53))) AS ?filename).
}
LIMIT 10000

Try it!

Zeitleiste von Dateien, die von einem Wikimedia Commons-Benutzer erstellt wurden

# 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:Timeline
SELECT ?file ?date WHERE {
  BIND("Coyau" AS ?username)
  ?file (p:P170/pq:P4174) ?username;
    wdt:P571 ?date.
}
LIMIT 1000

Try it!

Wartungsanfragen

Dateien, die mit einer Kamera aufgenommen wurden, bevor diese Kamera veröffentlicht wurde

select ?file ?file_date ?camera ?camera_date 
with {
  select * {
    # SELECT all camera models
    service <https://query.wikidata.org/sparql> {
      ?camera wdt:P31 wd:Q20741022;
               wdt:P571 ?camera_date.
    }
  }
} as %cameras
where {
  include %cameras .
  #select images taken with the camera
  ?file wdt:P4082 ?camera;
        wdt:P571 ?file_date.
  FILTER(?file_date < ?camera_date)

} LIMIT 1000

Try it!

Erkundung von Commons-Kategorien

Der Dienst wikibase: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" .

Wikidata-Items von Dateien in Category:Artworks with structured data with redirected digital representation of property

Die Wartungskategorie Category:Artworks with structured data with redirected digital representation of property sammelt Dateien mit der Anweisung digital 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_to
WITH
{
  SELECT ?file ?title
  WHERE
  {
    SERVICE wikibase:mwapi
    {
      bd:serviceParam wikibase:api "Generator" .
      bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
      bd:serviceParam mwapi:gcmtitle "Category:Artworks with structured data with redirected digital representation of property" .
      bd:serviceParam mwapi:generator "categorymembers" .
      bd:serviceParam mwapi:gcmtype "file" .
      bd:serviceParam mwapi:gcmlimit "max" .
      ?title wikibase:apiOutput mwapi:title .
      ?pageid wikibase:apiOutput "@pageid" .
    }
    BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
  }
} AS %get_files
WHERE
{
  INCLUDE %get_files
  ?file wdt:P6243 ?redirect_from .
  SERVICE <https://query.wikidata.org/sparql> {
      ?redirect_from owl:sameAs ?redirect_to.
  }
}

Try it!

Zeigt Aussagen mit niederländischen Bezeichnungen von Dateien in einer Commons-Kategorie an.

SELECT ?file ?title ?depicts ?depicts_label
WITH
{
  SELECT ?file ?title
  WHERE
  {
    SERVICE wikibase:mwapi
    {
      bd:serviceParam wikibase:api "Generator" .
      bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
      bd:serviceParam mwapi:gcmtitle "Category:Historia Naturalis van Rudolf II" .
      bd:serviceParam mwapi:generator "categorymembers" .
      bd:serviceParam mwapi:gcmtype "file" .
      bd:serviceParam mwapi:gcmlimit "max" .
      ?title wikibase:apiOutput mwapi:title .
      ?pageid wikibase:apiOutput "@pageid" .
    }
    BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
  }
} AS %get_files
WHERE
{
  INCLUDE %get_files
  ?file wdt:P180 ?depicts .
  service <https://query.wikidata.org/sparql> {
    OPTIONAL {?depicts rdfs:label ?depicts_label FILTER (lang(?depicts_label) = 'nl') } 
    }
}

Try it!

Kamerastandort der Dateien in einer Kategorie

#defaultView:Map
SELECT ?file ?title ?image ?coords 
WITH
{
  SELECT ?file ?title
  WHERE
  {
    SERVICE wikibase:mwapi
    {
      bd:serviceParam wikibase:api "Generator" .
      bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
      bd:serviceParam mwapi:gcmtitle "Category:River Ravensbourne" .
      bd:serviceParam mwapi:generator "categorymembers" .
      bd:serviceParam mwapi:gcmtype "file" .
      bd:serviceParam mwapi:gcmlimit "max" .
      ?title wikibase:apiOutput mwapi:title .
      ?pageid wikibase:apiOutput "@pageid" .
    }
    BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
  }
} AS %get_files
WHERE
{
  INCLUDE %get_files
  OPTIONAL {?file wdt:P1259 ?coords} .  # coords of POV      
  OPTIONAL {?file wdt:P9149 ?coords} .  # fallback: coords of depicted place
  FILTER(bound(?coords)) .
  ?file schema:url ?image.
}

Try it!

Weitere Abfragen

Einige Abfragen untersuchen, wie bestimmte Eigenschaften verwendet werden

Objekte mit der größten Anzahl digitaler Darstellungen (P6243)

Wikidata-Items mit der größten Anzahl von Dateien in Commons, die über die Anweisung digital representation of (P6243) mit ihnen verknüpft sind.

SELECT ?count ?item ?item_label ?commonscat_link

WITH {
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?item WHERE {
     ?file wdt:P6243 ?item . 
  } GROUP BY ?item
  ORDER BY DESC(?count)
  LIMIT 200
} AS %items

WHERE {
  INCLUDE %items . 
  service <https://query.wikidata.org/sparql> {
    OPTIONAL {?item rdfs:label ?item_label FILTER (lang(?item_label) = 'en') } .
    OPTIONAL {
      ?item wdt:P373 ?commonscat .
      BIND(IRI(CONCAT("https://commons.wikimedia.org/wiki/Category:", ?commonscat)) AS ?commonscat_link) .
    }
  }
} ORDER BY DESC(?count) ?item_label

Try it!

Anzahl der digitalen Darstellungen (P6243) nach Art des dargestellten Objekts

Hinweis - beschränkt auf eine Stichprobe von 50.000 Dateien, obwohl wir (derzeit) 225124 Dateien mit digital 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_label

WITH {
  SELECT ?file ?item WHERE {
     ?file wdt:P6243 ?item . 
  } LIMIT 50000
} AS %files

WHERE {
  INCLUDE %files . 
  service <https://query.wikidata.org/sparql> {
    ?item wdt:P31 ?class .
    OPTIONAL {?class rdfs:label ?class_label FILTER (lang(?class_label) = 'en') } .
  }
} GROUP BY ?class ?class_label
ORDER BY DESC(?count) ?class_label

Try it!

Häufigste Qualifikationsmerkmale, wenn „Bildquelle“ (P7482) = „Datei im Internet verfügbar“ (Q74228490)

# # Most frequent qualifier properties when "source of image" (P7482) = "file available on the internet" (Q74228490) 
#  based on sample of 100,000 such images
SELECT ?count ?qualifier ?qualifier_label ?example ?example_value ?example_value_label

WITH {
  SELECT ?file ?source_stmt WHERE {
     service bd:sample {
       ?source_stmt ps:P7482 wd:Q74228490 .
        bd:serviceParam bd:sample.limit 100000 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
     } 
     ?file p:P7482 ?source_stmt .
  } 
}  AS %files

WITH {
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?qualifier (SAMPLE(?file) AS ?example) (SAMPLE(?value) AS ?example_value) WHERE {
     INCLUDE %files .
     ?file p:P7482 ?source_stmt . 
     ?source_stmt ?qualifier ?value .
  } GROUP BY ?qualifier
  ORDER BY DESC(?count)
  LIMIT 200                      
} AS %source_info
 
WHERE {
  INCLUDE %source_info .
  service <https://query.wikidata.org/sparql> {
    ?qualifier ^wikibase:qualifier ?qual_item . 
    OPTIONAL {?qual_item rdfs:label ?qualifier_label FILTER (lang(?qualifier_label) = 'en') } .
    OPTIONAL {?example_value rdfs:label ?example_value_label FILTER (lang(?example_value_label) = 'en') } .
  }
}
ORDER BY DESC(?count)

Try it!

Häufigste Anbieter von Bildern, wenn „Bildquelle“ (P7482) = "Datei im Internet verfügbar" (Q74228490)

(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 ?example 

WITH {
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?provider (SAMPLE(?file) AS ?example) WHERE {
     service bd:sample {
       ?source_stmt ps:P7482 wd:Q74228490 .
        bd:serviceParam bd:sample.limit 10000 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
     }
     ?file p:P7482 ?source_stmt .      
     ?source_stmt pq:P137 ?provider .
  } GROUP BY ?provider
  ORDER BY DESC(?count)
  LIMIT 200                      
} AS %source_info
 
WHERE {
  INCLUDE %source_info .
  service <https://query.wikidata.org/sparql> {
    OPTIONAL {?provider rdfs:label ?provider_label FILTER (lang(?provider_label) = 'en') } .
  }
}
ORDER BY DESC(?count)

Try it!

Bilder mit der größten Anzahl von „Darstellungen“ (P180)-Werten, aber keinen bevorzugten Werte.

(from a non-random sample of 500,000 images)

# Images with largest number of depicts values

#defaultView:ImageGrid
SELECT ?count ?image (GROUP_CONCAT(?topicLabel; separator = ' / ') AS ?topicLabels)

WITH {
  SELECT ?file WHERE {
    ?file a wikibase:Mediainfo .
  } LIMIT 500000
} AS %files

WITH {
  SELECT ?file ?topic WHERE {
    INCLUDE %files .
    MINUS {?file p:P180/wikibase:rank wikibase:PreferredRank} .
    ?file wdt:P180 ?topic .
  }
} AS %file_topics 

WITH {
  SELECT (COUNT(DISTINCT(?topic)) AS ?count) ?file WHERE {
    INCLUDE %file_topics .
  } GROUP BY ?file
  ORDER BY DESC(?count)
  LIMIT 200
} AS %top_files

WITH {
  SELECT ?count ?file ?topic WHERE {
     INCLUDE %file_topics .
     INCLUDE %top_files .
  }
} AS %top_file_topics

WITH {
  SELECT DISTINCT ?topic WHERE {
      INCLUDE %top_file_topics .
  }
} AS %top_topics

WITH{
  SELECT ?topic ?topicLabel WHERE {
    INCLUDE %top_topics .
    service <https://query.wikidata.org/sparql> {
       service wikibase:label {
        bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
        ?topic rdfs:label ?topicLabel.
      }
    }
  }
} AS %topicLabels

WHERE {
   INCLUDE %top_file_topics .
   INCLUDE %topicLabels .
   ?file schema:contentUrl ?url .
   bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)
} GROUP BY ?count ?file ?image 
ORDER BY DESC(?count)

Try it!

Dateien mit doppelten Anweisungen „zeigt“ (P180)

Suche alle Dateien mit demselben Wert, die zweimal zu derselben Eigenschaft hinzugefügt wurden. In diesem Beispiel haben wir die Anweisung depicts (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

SELECT DISTINCT ?file {
  ?file p:P180 ?statement1.
  ?file p:P180 ?statement2.
  ?statement1 ps:P180 ?value .
  ?statement2 ps:P180 ?value .
  FILTER(?statement1 != ?statement2)
}
limit 50

Try it!

Dinge, die mit Katzen dargestellt werden

# Things depicted with cats

#defaultView:ImageGrid
SELECT ?count ?depicted ?depictedLabel ?sampleImg

WITH {
  SELECT ?target WHERE {
    SERVICE <https://query.wikidata.org/sparql> {   
        { ?target wdt:P31?/wdt:P279* wd:Q146 }     ## include specific sorts of cats and individual cats
        UNION
        { ?target wdt:P31? wd:Q43577 }              ## and also breeds of cat
    }
  }
} AS %targets
    
WITH {
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?depicted (SAMPLE(?file) AS ?sample) WHERE {
    INCLUDE %targets .
    ?file p:P180 ?stmt .
    ?stmt ps:P180 ?target .
 #   ?stmt wikibase:rank wikibase:PreferredRank .       ##  Make sure the cat is marked as prominent -- **commented out for now**
    
    ?file p:P180 ?stmt2.  FILTER (?stmt2 != ?stmt) .    ##  now get another depicts statement
    ?stmt2 ps:P180 ?depicted . 
  } GROUP BY ?depicted
} AS %things 

WITH {
  SELECT ?count ?depicted ?sample WHERE {
    INCLUDE %things .
    MINUS {                                           ## exclude anything that was an original target
      SELECT (?target AS ?depicted) WHERE {
        INCLUDE %targets .
      }
    }
  }
} AS %things1

WHERE {
  INCLUDE %things1 .
  SERVICE <https://query.wikidata.org/sparql> {
    SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
      ?depicted rdfs:label ?depictedLabel .
    }
  }
  ?sample schema:contentUrl ?url;
          schema:url ?sampleImg.
} ORDER BY DESC(?count)

Try it!

  • mit einem zufälligeren Satz von abgetasteten Bildern: tinyurl.com/y35wjrz8 (die Auswahl ist jedes Mal anders, wenn die Abfrage geändert wird oder wenn sie sich nicht mehr im Cache befindet)

Bilder aufgenommen 1 km um ein Zentrum

#defaultView:Map{"hide":["?coor"]}
# query by Jura1, 2020-11-12
SELECT ?fileLabel ?fileDescription ?image ?coor
WHERE 
{
  hint:Query hint:optimizer "None".
  SERVICE <https://query.wikidata.org/sparql> { wd:Q43244 wdt:P625 ?center }  # Wikidata item with coordinates
  SERVICE wikibase:around {
      ?file wdt:P1259 ?coor.
      bd:serviceParam wikibase:center ?center .
      bd:serviceParam wikibase:radius "1". # 1 kilometer around
  }  
  ?file schema:contentUrl ?url .
  bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

Try it!

  • Das Zentrum wird durch die Koordinaten bei d:Q43244#P625 definiert

Wikimedia Commons Bewertungen

Wertvolle Bilder von Leichtathletik-Wettbewerber

#shows files that depict athletics competitors and with the Valued Image assessment 
#defaultView:ImageGrid
SELECT ?file ?image

WITH {
  SELECT ?item WHERE {
    SERVICE <https://query.wikidata.org/sparql> {
      ?item wdt:P106 wd:Q11513337 .
    }
  }
} AS %get_items

WHERE {
  INCLUDE %get_items
  ?file wdt:P180 ?item .
  ?file wdt:P6731 wd:Q63348040 .  # Commons valued image
  ?file schema:url ?image .
}

Try it!

Qualitätsbilder, die Kolibris darstellen

#shows files that depict Hummingbirds and with the Quality Image assessment 
#defaultView:ImageGrid
SELECT ?file ?image

WITH {
  SELECT ?item WHERE {
    SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P171/wdt:P171* wd:Q43624.
    } 
  }
} AS %get_items

WHERE {
  INCLUDE %get_items
  ?file wdt:P180 ?item .
  ?file wdt:P6731 wd:Q63348069 .  # Commons quality image
  ?file schema:url ?image .
}

Try it!

Qualitätsbilder, die Bogenbrücken in Italien darstellen

#shows files that depict arch bridges in Italy and with the Quality Image assessment 
#defaultView:ImageGrid
SELECT ?file ?image

WITH {
  SELECT ?item WHERE {
    SERVICE <https://query.wikidata.org/sparql> {
      ?item wdt:P31 wd:Q158438 .
      ?item wdt:P17 wd:Q38 .
    }
  }
} AS %get_items

WHERE {
  INCLUDE %get_items
  ?file wdt:P180 ?item .
  ?file schema:url ?image .
  ?file wdt:P6731 wd:Q63348069 .
}

Try it!

Ausgewählte Bilder, die Schmetterlinge darstellen und mit einer Canon-Kamera aufgenommen wurden

#shows files that depict Lepidoptera, with the Featured Picture assessment, and taken with a Canon camera
#defaultView:ImageGrid

SELECT ?file ?image

WITH {
  SELECT ?item WHERE {
    SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P171/wdt:P171* wd:Q28319.
     } 
  }
} AS %get_items

WHERE {
  INCLUDE %get_items
  ?file wdt:P180 ?item .
  ?file schema:url ?image .
  ?file wdt:P6731 wd:Q63348049 .
  ?file wdt:P4082 ?camera.
  SERVICE <https://query.wikidata.org/sparql> {
     ?camera wdt:P1716 wd:Q63554165 .     # brand = Canon
  } 
}

Try it!

Häufig verwendete Eigenschaften auf Commons

Die häufigsten Prädikate für Commons-Elemente, die Douglas Adams darstellen

#most common predictates on Commons items that depict Douglas Adams
SELECT (COUNT(DISTINCT(CONCAT(str(?file),str(?value)))) AS ?count) ?prop (SAMPLE(?file) AS ?sample_file)  (SAMPLE(?value) AS ?sample_value) 

WHERE {
  ?file wdt:P180 wd:Q42 .
  ?file ?prop ?value .
} GROUP BY ?prop
ORDER BY DESC(?count)

Try it!

Prädikate/Eigenschaften und ihre Bezeichnungen in natürlicher Sprache, die bei Commons-Artikeln verwendet werden, die Douglas Adams darstellen

SELECT DISTINCT ?prop ?propLabel WHERE {
  ?file wdt:P180 wd:Q42 ;
        schema:contentUrl ?contentURL ;
        ?p ?o .
  SERVICE <https://query.wikidata.org/sparql> {
      ?prop wikibase:claim ?p ;
            rdfs:label ?propLabel .
      FILTER (lang(?propLabel) = "en")
    }
}

Try it!

Die häufigsten Prädikate für eine Stichprobe von 5.000 Commons-Dateien

  • Diese Abfrage verwendet den Verbund, um die Namen der Eigenschaften in Wikidata nachzuschlagen (eine Aufgabe, die für Eigenschaften etwas komplizierter ist als für reguläre Wikidata-Elemente).

Eine Reihe benannter Unterabfragen (z. B. die WITH-Blöcke) werden verwendet, um die Ausführungssequenz zu erzwingen - siehe Wikidata für ein wenig mehr dazu.

#most common predictates on a sample of 5,000 Commons files
SELECT (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 ?file WHERE {
     service bd:sample {
       ?file a wikibase:Mediainfo .
        bd:serviceParam bd:sample.limit 5000 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
     }
  }  
} AS %files

WITH {
  SELECT ?file ?prop ?val WHERE {
    INCLUDE %files .
    ?file ?prop ?val .
  } 
} AS %triples

WITH {
  SELECT DISTINCT ?prop WHERE {
     INCLUDE %triples .
  }
} AS %props

WITH {
   SELECT ?prop ?prop_label WHERE {
     INCLUDE %props .
     service <https://query.wikidata.org/sparql> {
        OPTIONAL {
           ?prop ^wikibase:directClaim ?prop_item .
           ?prop_item rdfs:label ?prop_label FILTER (lang(?prop_label) = 'en') .
        }
        OPTIONAL {
           ?prop ^wikibase:claim ?prop_item .
           ?prop_item rdfs:label ?prop_label FILTER (lang(?prop_label) = 'en') .
        }
     }
  }
} AS %prop_labels
     
WHERE {
  INCLUDE %triples .
  INCLUDE %prop_labels .
} GROUP BY ?prop ?prop_label
ORDER BY DESC(?stmt_count)

Try it!

  • Weitere 5000: tinyurl.com/yyuywxqm

Die am häufigsten verwendeten Qualifikationsmerkmale für „Darstellungen“-Anweisungen

# Most common qualifiers used on "depicts" statements
SELECT DISTINCT ?count ?qual ?qual_label ?sample_file ('depicts' AS ?prop) ?sample_stmt_value ?sample_stmt_valueLabel (?qual_label AS ?qualLabel1) ?sample_value ?sample_valueLabel

WITH {
  SELECT ?qual  WHERE {
    service <https://query.wikidata.org/sparql> {
      ?prop wikibase:qualifier ?qual .
    }
  }
} AS %quals 

WITH {
  SELECT ?stmt ?qual WHERE {
    INCLUDE %quals .
    ?stmt ?qual [] .
    ?file p:P180 ?stmt .
  } LIMIT 30000
} AS %stmts 

WITH {
  SELECT (COUNT(DISTINCT(?stmt)) AS ?count) ?qual (SAMPLE(?stmt) AS ?example_stmt) WHERE {
     INCLUDE %stmts .
  } GROUP BY ?qual 
} AS %top_quals

WITH {
  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_stmt ps:P180 ?example_stmt_value .
    ?example_stmt ?qual ?example_value .
  } GROUP BY ?count ?qual
} AS %results
 
WHERE {
  INCLUDE %results .
  service <https://query.wikidata.org/sparql> {
    ?qual ^wikibase:qualifier ?qual_item
    service wikibase:label { 
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
      ?qual_item rdfs:label ?qual_label.
      ?sample_stmt_value rdfs:label ?sample_stmt_valueLabel .
      ?sample_value rdfs:label ?sample_valueLabel .
    }
  } 
}  ORDER BY DESC(?count)

Try it!

Die gebräuchlichsten Kombinationen von Eigenschaften und Qualifizierern, außer den Anweisungen „zeigt“ (P180)

# most common property + qualifier combinations, other than on "depicts" (P180) statements
SELECT ?count ?pred ?pred_label ?qual ?qual_label ?example

WITH {
  SELECT ?qual  WHERE {
    service <https://query.wikidata.org/sparql> {
      ?prop wikibase:qualifier ?qual .
    }
  }
} AS %quals 

WITH {
  SELECT ?file ?stmt ?qual ?pred WHERE {
    INCLUDE %quals .
    ?stmt ?qual [] .
    OPTIONAL {?f1 p:P180 ?stmt} FILTER(!bound(?f1)) .
    ?file ?pred ?stmt .
  } LIMIT 100000
} AS %stmts 

WITH {
  SELECT (COUNT(DISTINCT(?stmt)) AS ?count) ?qual ?pred (SAMPLE(?file) AS ?example) WHERE {
     INCLUDE %stmts .
  } GROUP BY ?qual ?pred 
} AS %top_quals

WHERE {
  INCLUDE %top_quals .
  service <https://query.wikidata.org/sparql> {
        OPTIONAL {
           ?pred ^wikibase:claim ?pred_item .
           ?pred_item rdfs:label ?pred_label FILTER (lang(?pred_label) = 'en') .
        }
        OPTIONAL {
           ?qual ^wikibase:qualifier ?qual_item .
           ?qual_item rdfs:label ?qual_label FILTER (lang(?qual_label) = 'en') .
        }
  }
}  ORDER BY DESC(?count)

Try it!

Am häufigsten verwendet werden Aussagen aus einem Teil der Mediendateien, für die es keine Übersetzungen ins Spanische gibt

SELECT ?depicts ?count ?depictsLabel_en ?depictsLabel_es WITH {

SELECT ?depicts (count(?file) as ?count) WHERE
{
   SERVICE bd:slice {
?file wdt:P180 ?depicts.
    bd:serviceParam bd:slice.offset 10000000 . # Start at item number (not to be confused with QID)
    bd:serviceParam bd:slice.limit 3000000 . # List this many items to prevent query timeout
  }
} group by ?depicts having (?count>10 && ?count<4000000) } AS %I
WHERE
{
  INCLUDE %I
  SERVICE <https://query.wikidata.org/sparql> {
    filter not exists {?depicts rdfs:label ?depictsLabel_es FILTER (lang(?depictsLabel_es) = 'es') }  
    OPTIONAL {?depicts rdfs:label ?depictsLabel_en FILTER (lang(?depictsLabel_en) = 'en') }
  }
} order by desc(?count)

Try it!

Bearbeitungen erzeugen

Quickstatements direkt aus SPARQL generieren

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 in Quickstatements kopieren/einfügen können. Beispiel:

-STATEMENT | M58764743$D563143B-0F5C-403E-AE11-4BB744B7E267

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

SELECT DISTINCT ?quickstatement WHERE {
  # Wikidata items of P180 terms we want to remove
  VALUES ?exclude { wd:Q467 wd:Q8441 }
  ?file wdt:P3634 ?metid .
  ?file p:P180 ?fullstatement .
  ?fullstatement ps: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)
  ?fullstatement ps:P180 []; pq:P459 wd:Q106429444 ; prov:wasDerivedFrom ?ref  . 
  ?ref pr:P248 ?statedin .  # Met tagging initiative
  ?ref pr: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/statement
  BIND(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)
}

Try it!