User:2le2im-bdc/SPARQL

From Wikidata
Jump to navigation Jump to search

Divers[edit]

Les autres pages de ressources SPARQL[edit]

  • les requêtes formulées dans le cadre du Forum des archivistes à Saint-Etienne.
  • Le mémo sur les requêtes sur les Wikipedia.

Parmi un groupe choisi d'éléments[edit]

SELECT ?item ?itemLabel 
WHERE 
{
  ?item  wdt:P735 wd:Q3480335. 
  FILTER (?item IN (wd:Q767, wd:Q66112, wd:Q545580, wd:Q228546)).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Nombre de déclaration P485[edit]

#Comptabiliser les nombre de déclarations différentes de P485 pour chacun des éléments archivé par une institution donnée.
SELECT ?item ?itemLabel (COUNT(?archives) as ?count)
WHERE 
{
  ?item wdt:P485 wd:Q2860507;
        wdt:P485 ?archives.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Group BY ?item ?itemLabel ?count
ORDER BY DESC (?count)
Try it!

ID externe[edit]

SELECT ?item ?itemLabel 
WHERE 
{
  ?item wdt:P902 ?DHS.
  FILTER (?DHS = "029396").
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

VALUES[edit]

#l'utilisation par les autres wiki de l'item "Gambling, Gods And LSD"
SELECT ?item ?itemLabel ?article WHERE 
{
  VALUES ?items { wd:Q1492988 }
  ?article schema:about ?items.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

String[edit]

#movie with P973 start with "https://www.artfilm.ch"
SELECT ?item ?itemLabel ?value ?title 
WHERE 
{
  ?item wdt:P31 wd:Q2431196;
        wdt:P973 ?value . 
  FILTER( REGEX(str(?value),"^https://www\\.artfilm\\.ch" ) )
  OPTIONAL { ?item wdt:P1476 ?title }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,it,de,rm,en". }
}
Try it!

Ou en plus simple :

#movie with P973 start with "https://www.artfilm.ch"
SELECT DISTINCT ?item ?itemLabel
WHERE 
{
  ?item wdt:P31 wd:Q2431196;
        wdt:P973 ?describes.
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch")
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

artfilm[edit]

Voir page dédiée à ce projet.

Général[edit]

#films mis à disposition en libre accès en VOD par artfilm.ch durant la crise du Covid-19
SELECT DISTINCT ?film ?filmLabel (GROUP_CONCAT(DISTINCT(?réalLabel); separator=", ") as ?réals) ?duree (MIN(?date) as ?oldest_date) ?decrit 
WHERE 
{
  ?film wdt:P1344 wd:Q89370484;
        wdt:P2047 ?duree;
        wdt:P577 ?date;
        wdt:P57 ?réal.
  ?film p:P973 ?describestmt.
  ?describestmt ps:P973 ?decrit.
  ?describestmt pq:P407 wd:Q150.
  FILTER STRSTARTS(STR(?decrit), "https://www.artfilm.ch").
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,it,es".
                         ?réal rdfs:label ?réalLabel.
                         ?film rdfs:label ?filmLabel.
                         }
}
GROUP BY ?film ?filmLabel ?duree ?decrit
Try it!

FILTER STRSTARTS[edit]

#movie with P973 start with "https://www.artfilm.ch"
SELECT DISTINCT ?réal ?réalLabel ?decrit ?genreLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P973 ?describes;
        wdt:P57 ?réal.
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch").
  OPTIONAL{?réal wdt:P21 ?genre.}
  OPTIONAL{?réal wdt:P973 ?decrit.}
  FILTER NOT EXISTS {?réal wdt:P569 ?naissance.}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de". }
}
ORDER BY ?réalLabel
Try it!
#movie with P973 start with "https://www.artfilm.ch"
SELECT DISTINCT ?item ?itemLabel ?réal ?réalLabel ?famLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P973 ?describes;
        wdt:P57 ?réal
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch").
  ?réal wdt:P734 ?fam.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de".
    ?item rdfs:label ?itemLabel.
    ?réal rdfs:label ?réalLabel.
    ?fam rdfs:label ?famLabel.
}
}
ORDER BY STR(?famLabel)
Try it!

p, ps, pq[edit]

#movie with P973 start with "https://www.artfilm.ch" and in french
SELECT DISTINCT ?item ?itemLabel ?decrit ?réal ?réalLabel ?famLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P57 ?réal.
  ?item p:P973 ?describestmt.
  ?describestmt ps:P973 ?decrit.
  ?describestmt pq:P407 wd:Q150.
  FILTER STRSTARTS(STR(?decrit), "https://www.artfilm.ch").
  ?réal wdt:P734 ?fam.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de".
    ?item rdfs:label ?itemLabel.
    ?réal rdfs:label ?réalLabel.
    ?fam rdfs:label ?famLabel.
}
}
ORDER BY STR(?famLabel)
Try it!

MINUS[edit]

#director of movie with P973 "artfilm.ch" sans P734 (nom de famille)
SELECT DISTINCT ?réal ?réalLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P973 ?describes;
        wdt:P57 ?réal
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch").
  MINUS {?réal wdt:P734 ?fam.}.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de".}
}
Try it!
#director of movie with P973 "artfilm.ch" sans date de naissance
SELECT DISTINCT ?réal ?réalLabel ?réaldes
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P973 ?describes;
        wdt:P57 ?réal
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch").
  MINUS {?réal wdt:P569 ?born.}.
  ?réal wdt:P973 ?réaldes.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de".}
}
Try it!
#director of movie with P973 "artfilm.ch" sans date de naissance
SELECT DISTINCT ?réal ?réalLabel ?réaldes
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P973 ?describes;
        wdt:P57 ?réal
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch").
  MINUS {?réal wdt:P569 ?born.}.
  ?réal wdt:P973 ?réaldes.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de".}
}
Try it!
#movie with P973 "artfilm.ch" sans date de publication (#44 le 4 avril 2020)
SELECT DISTINCT ?item ?itemLabel
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q2431196;
        wdt:P973 ?describes;
  FILTER STRSTARTS(STR(?describes), "https://www.artfilm.ch").
  MINUS {?item wdt:P577 ?date.}
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,it,de".}
}
Try it!

Autres[edit]

#films mis à disposition en libre accès en VOD par artfilm.ch durant la crise du Covid-19 (manque les réalisateurs (demande d'aide en cours))
SELECT DISTINCT ?film ?filmLabel (GROUP_CONCAT(DISTINCT(?réalLabel); separator=", ") as ?réals) ?duree (GROUP_CONCAT(DISTINCT(?date); separator=", ") as ?dates) ?decrit 
WHERE 
{
  ?film wdt:P1344 wd:Q89370484;
        wdt:P2047 ?duree;
        wdt:P577 ?date;
        wdt:P57 ?réal.
  ?film p:P973 ?describestmt.
  ?describestmt ps:P973 ?decrit.
  ?describestmt pq:P407 wd:Q150.
  FILTER STRSTARTS(STR(?decrit), "https://www.artfilm.ch").
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,it,es".}
}
GROUP BY ?film ?filmLabel ?duree ?decrit
Try it!

GLAM[edit]

#Les types d'éléments archivé par une institution
SELECT ?type ?typeLabel (COUNT(?type) AS ?count)
WHERE 
{
  ?item wdt:P485 wd:Q182542;#l'institution en question
        wdt:P31 ?type.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?type ?typeLabel
ORDER BY DESC (?count)
Try it!