User:Hsarrazin/SPARQL

From Wikidata
Jump to navigation Jump to search

https://w.wiki/4Q7K (pour sortir la liste des personnes avec un certain nom -> P734/735)

Aides et guides[edit]

et voir sur wikisource pour requêter https://data.bnf.fr/sparql/ -> discussion pour monter la requête

Badges mal appliqués[edit]

Lexèmes[edit]

Sum of all paintings[edit]

Dates à traiter[edit]

date 1/1/1953 en siècle[edit]

SELECT ?item ?itemLabel ?time
WHERE
{
  ?item p:P569/psv:P569 [wikibase:timePrecision 7 ; wikibase:timeValue ?time].
  FILTER (   YEAR(?time) = 1953 ).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

à copier/coller sur wdfist pour recherche par année[edit]

SELECT ?item ?itemLabel WHERE {  ?item wdt:P570 ?date.  FILTER (year(?date) = 2016 )}

Date de naissance dans l'avenir[edit]

tinyurl.com/jb8yjls

SELECT ?Person ?PersonLabel ?DateOfBirth WHERE {
  ?Person wdt:P31 wd:Q5.
  ?Person wdt:P569 ?DateOfBirth.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  FILTER(?DateOfBirth > (NOW()))
}
ORDER BY ?DateOfBirth
Try it!

Date de décès dans l'avenir[edit]

tinyurl.com/hsev4nm

SELECT ?Person ?PersonLabel ?DateOfDeath WHERE {
  ?Person wdt:P31 wd:Q5.
  ?Person wdt:P570 ?DateOfDeath.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  FILTER(?DateOfDeath > (NOW()))
}
ORDER BY ?DateOfDeath
Try it!

Ecrivains lacunaires[edit]

https://w.wiki/4oKA Auteurs avec P31 sourcé par importé + Bnf (à nettoyer)

doublons de viaf[edit]

tinyurl.com/y9epdten

manque VIAF[edit]

tinyurl.com/hgqknmf

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P106 wd:Q201788.
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikipedia.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
  FILTER(NOT EXISTS { ?item wdt:P214 ?foo. })
}
Try it!

Historiens manque VIAF[edit]

tinyurl.com/j3p2def

# Historians with links to French Wikipedia or Wikisource, but missing VIAF id
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q5 .
  ?item wdt:P106 wd:Q201788 .
  
  # Here we ask people with no VIAF id
  FILTER NOT EXISTS { ?item wdt:P214 ?viaf . }
  # But the ones we already know they don't have one show up anyway
  # so we filter out people with "No value" for VIAF id
  FILTER NOT EXISTS { ?item rdf:type wdno:P214 . }
  
  ?wikilink schema:about ?item .
  { ?wikilink schema:isPartOf <https://fr.wikisource.org/> . } UNION {
    ?wikilink schema:isPartOf <https://fr.wikipedia.org/> . }
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . }
}
Try it!

manque BNF[edit]

https://w.wiki/3F$$

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel ?dob WHERE {
  ?item wdt:P106 wd:Q201788.
  ?item wdt:P27 wd:Q142.
  OPTIONAL {?item wdt:P569 ?dob.}
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikipedia.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
  FILTER(NOT EXISTS { ?item wdt:P268 ?bnf. })
}

ORDER BY DESC(?dob)
Try it!

VIAF manque ISNI[edit]

tinyurl.com/yd3cacgd

SELECT ?item ?dod ?itemLabel ?itemDescription ?nom ?viaf
WHERE
{
	?item wdt:P570 ?dod .
	FILTER ( ?dod >= "2017-01-01T00:00:00Z"^^xsd:dateTime && ?dod <= "2017-12-31T00:00:00Z"^^xsd:dateTime )
  	?item wdt:P31 wd:Q5 .
  	?item wdt:P214 ?viaf.
  
  	OPTIONAL { ?item wdt:P1559 ?nom }
  	OPTIONAL { ?item wdt:P213 ?isni }
  	FILTER(!bound(?isni))
	SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }  
}
ORDER BY ASC(?dod)

Limit 2000
Try it!

manque Langue d'expression[edit]

tinyurl.com/zxb5sol

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P106 wd:Q201788.
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikipedia.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
  FILTER(NOT EXISTS { ?item wdt:P1412 ?foo. })
}
Try it!

Français (avec BNF) mais sans Langue d'expression[edit]

tinyurl.com/zg3fjs8

# French people with a BNF ID and no spoken language
SELECT ?item ?itemLabel ?Bnf ?Naissance WHERE {
  ?item wdt:P31 wd:Q5 .
  ?item wdt:P268 ?Bnf .
  ?item wdt:P27 wd:Q142 .
  ?item wdt:P569 ?Naissance .
  FILTER NOT EXISTS { ?item wdt:P1412 ?foo . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr, en" . } .
} ORDER BY DESC(?birthDate)
Try it!

Projet Noms[edit]

Noms à appliquer sur personnes[edit]

  • noms non utilisés, à checker tinyurl.com/y7eeqek8 1190 on 12:53, 5 November 2017 (UTC)
  • Noms de familles (propres) à vérifier sur wikidata tinyurl.com/h74f9f4

Prénoms liés à revoir[edit]

Note : modifier le code du prénom pour checker les liens...

  • tinyurl.com/ya7wgw6o
SELECT ?item ?label ?nom (LANG(?nom) AS ?nomLang) WHERE {
  ?item wdt:P735 wd:Q20187.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "fr,ru" . 
    ?item rdfs:label ?label
  }
  
OPTIONAL { ?item wdt:P1559 ?nom. }
}
LIMIT 2000
Try it!

pour rechercher une chaîne de caractère au début d'un nom[edit]

SELECT ?item ?itemlabel
WHERE {
  ?item wdt:P734 wd:Q16880652 . #Oda
  ?item rdfs:label ?itemlabel .
  FILTER (lang(?itemlabel) = "ja"). 
  FILTER(STRSTARTS(?itemlabel, '織田')) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "ja" . }
  }
Try it!

pour rechercher une chaîne de caractère à la fin d'un nom[edit]

SELECT ?item ?orig
WHERE {
  ?item wdt:P734 wd:Q686223 . #Li
  ?item wdt:P1559 ?orig .
  FILTER(STRENDS(?itemlabel, 'Li')) .
  }
Try it!

Divers[edit]

Etudiants RADA n'ayant pas diplômé[edit]

  • usage pour propriété "novalue" tinyurl.com/gmaoed8
SELECT ?student ?studentLabel where {
  ?student p:P69 ?school .
  ?school ps:P69 wd:Q523926 .
  ?school rdf:type wdno:P512 .
    SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}
Try it!

langues en alphabet latin[edit]

tinyurl.com/y8gt94fm

les items avec badges (à revoir)[edit]

SELECT ?item ?badge WHERE {
	?article schema:about ?item .
	?article  wikibase:badge ?badge .
}
Try it!

Outils de wikidata[edit]

tinyurl.com/h4rpdkh

SELECT ?tool ?toolLabel ?URL WHERE {
  ?tool wdt:P31 wd:Q21073501.  
  OPTIONAL {
    ?tool wdt:P856 ?URL
}  
  SERVICE wikibase:label {
 bd:serviceParam wikibase:language "en" .
}
}
Try it!

human (Q5)[edit]

instance of (P31) manquant[edit]

  • P21 sans P31 tinyurl.com/y74tc6ba - vu le 14/1/2018
  • P570 sans P31 tinyurl.com/yahxt2hs - vu le 14/1/2018
  • P569 sans P31 tinyurl.com/y7vlsqqs

problème avec sex or gender (P21)[edit]

  • personnes avec sex or gender (P21)male organism (Q44148) (au lieu sex or gender (P21)male (Q6581097)) tinyurl.com/ybat6rlv ou tinyurl.com/ydgpkvyt
  • personnes avec P1559 (alphabet latin) sans genre tinyurl.com/ycstqnwh - peu de résultats - à lancer de temps en temps - dernier passage : 5/11/2017
  • décès en 2018 sans P21 tinyurl.com/y7ssyxkj - décès en 2016 sans P21 tinyurl.com/yc7wc32j
  • ORCID without P21 tinyurl.com/yd93fl82

libellés fr à ajouter[edit]

images à ajouter[edit]

  • Décès en 2015, sans image
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P570 ?date.
  FILTER (year(?date) = 2015 )
  MINUS {    ?item wdt:P18 ?nat.    }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .}
}
Try it!

prénoms à ajouter[edit]

Personnes mortes en 2015 (à modifier) et sans prénom (à modifier)[edit]
  • tinyurl.com/hqgs785
# personnes mortes en 2015, sans prénom, et sans label fr…
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?item ?itemLabel ?dod ?dob  WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P570 ?dod.
  FILTER(NOT EXISTS { ?item wdt:P735 ?prenom. })
  FILTER((?dod < "2016-00-00T00:00:00Z"^^xsd:dateTime) && (?dod >= "2015-00-00T00:00:00Z"^^xsd:dateTime))
  OPTIONAL { ?item rdfs:label ?itemLabel . FILTER(LANG(?itemLabel)="fr") . }
  OPTIONAL { ?item wdt:P569 ?dob.}
}
ORDER BY DESC(?dod)
Try it!

personnes mortes ces 30 derniers jours, sans nationalité[edit]

  • tinyurl.com/zuvhcvw
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?person ?personLabel ?died WHERE {
  ?person wdt:P31 wd:Q5;
          wdt:P570 ?died.
  MINUS {
  ?person wdt:P27 ?nationality.
}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  FILTER(?died >= ((NOW()) - "P30D"^^xsd:duration))
}
ORDER BY ?died
Try it!

Décès des 7 derniers jours[edit]

tinyurl.com/h6vt2ca

SELECT ?human ?humanLabel ?date
WHERE
{
  ?human wdt:P31 wd:Q5 .
  ?human wdt:P570 ?date .
  FILTER(BOUND(?date) && DATATYPE(?date) = xsd:dateTime).
  BIND(NOW() - ?date AS ?distance).
  FILTER(0 <= ?distance && ?distance < 7).
    SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
}
  } ORDER BY DESC (?date)
Try it!

Décès en 2017, sans libellé FR[edit]

tinyurl.com/yc8mh7dw

SELECT ?item ?dod ?itemLabel ?itemDescription ?nom
WHERE
{
	?item wdt:P570 ?dod .
	FILTER ( ?dod >= "1982-00-00"^^xsd:dateTime && ?dod <= "1982-12-31"^^xsd:dateTime )
  	?item wdt:P31 wd:Q5 .
  	OPTIONAL { ?item wdt:P569 ?v }
  	OPTIONAL { ?item wdt:P1559 ?nom }
 FILTER(NOT EXISTS {
   ?item rdfs:label ?lang_label.
   FILTER(LANG(?lang_label) = "fr")
})
	SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,es,it,nl,pl". }  
}
Try it!

Auteurs wikisource[edit]

Liste des oeuvres/éditions (avec choix de l'auteur)[edit]

Occupations par fréquence[edit]

tinyurl.com/h3qeaqr

PREFIX schema: <http://schema.org/>

SELECT (COUNT(?item) AS ?count) ?occupation ?occupationLabel WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P106 ?occupation.
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikisource.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
} GROUP BY ?occupation ?occupationLabel
Try it!

Pays par fréquence[edit]

tinyurl.com/z7ybkq8

PREFIX schema: <http://schema.org/>

SELECT (COUNT(?item) AS ?count) ?pays ?paysLabel WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P27 ?pays.
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikisource.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
} GROUP BY ?pays ?paysLabel
Try it!

Fonction par fréquence[edit]

tinyurl.com/jhh3csr

PREFIX schema: <http://schema.org/>

SELECT (COUNT(?item) AS ?count) ?fonction ?fonctionLabel WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P39 ?fonction.
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikisource.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
} GROUP BY ?fonction ?fonctionLabel
Try it!

Courants artistiques par fréquence[edit]

tinyurl.com/hrtoqam

PREFIX schema: <http://schema.org/>

SELECT (COUNT(?item) AS ?count) ?mouvement ?mouvementLabel WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P135 ?mouvement.
  ?article schema:about ?item.
  ?article schema:isPartOf <https://fr.wikisource.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
} GROUP BY ?mouvement ?mouvementLabel
Try it!