User:Pmartinolli/Fun SPARQL


Épigraphes

edit

Tous les épigraphes dans les littératures de l'imaginaire

edit

Speculative fiction : fantasy, SF, etc.

SELECT DISTINCT ?item ?itemLabel ?epi ?ref WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P7150 ?epi.  
  ?item wdt:P136/wdt:P279* wd:Q9326077.   
  OPTIONAL {?epi pq:P5997 ?ref.}  #comment récupérer la valeur ? 
  OPTIONAL {?item wdt:P577 ?year.}
}
ORDER BY ?year
Try it!

aussi

À améliorer : inclure toutes les oeuvres incluses (Published in) une oeuvre de genre=Speculative fiction. Exemple : inclure les chapitres/nouvelles du Roi en jaune.

À améliorer : fusionner les oeuvres génériques et les versions (ex: Roi en jaune).

Les œuvres avec le plus d'épigraphes

edit
SELECT DISTINCT ?work ?workLabel (COUNT(?epi) AS ?count)
WHERE
{
    ?work wdt:P7150 ?epii. # selection de tous les items avec un epigraph pour optimiser la requête
    ?work wdt:P136/wdt:P279* wd:Q9326077.    # filtre pour n'avoir que les oeuvres de l'imaginaire
    OPTIONAL {?work wdt:P7150 ?epi .}   # les oeuvres avec epigraphe
    OPTIONAL {?work wdt:P527 ?work2     # + les parties d'oeuvres avec un epigraphe 
                 {SELECT ?work2 WHERE  { ?work2 wdt:P7150 ?epi. } limit 100000 } }
    SERVICE wikibase:label {bd:serviceParam wikibase:language "en" .}
}
GROUP BY ?work ?workLabel
HAVING (?count > 0)
ORDER BY DESC(?count)
Try it!

Combien d'épigraphes dans Wikidata ?

edit
SELECT (COUNT(*) AS ?count) WHERE {  ?item wdt:P7150 ?epi.}
Try it!

Tous les personnages des histoires de Jin Yong

edit
SELECT DISTINCT ?item ?itemLabel ?item2 ?item2Label WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q15632617 # fictional human
  {?item (wdt:P170|wdt:P50) wd:Q180626. }   # creator author : Jin Yong
  UNION
  {?item wdt:P1441 ?item2.     # present in work by 
  {SELECT ?item2 WHERE  { 
       ?item2 wdt:P50 wd:Q180626.  # Jin Yong
       } limit 100000 }  }
}
Try it!

Toutes les œuvres contenant une carte fantastique

edit

Basé sur le compte @Mythicmaps

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P2283 wd:Q5434353.
}
Try it!
qid,P2283
Q0000000,Q5434353

En cours : Twitter query from:mythicmaps since:2022-01-01 until:2022-05-24

Toutes les oeuvres fictive dans des oeuvres de fiction

edit
SELECT DISTINCT ?item ?itemLabel ?item2 ?item2Label ?item3 ?item3Label WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31*/wdt:P279*  wd:Q15306849.   # all fictitious works and subclasses of fictitious work
  OPTIONAL {?item wdt:P1441 ?item2. }    # present in which work  
  OPTIONAL {?item wdt:P1080 ?item3. }    # from narrative universe  
}
Try it!

Astres du systeme solaire et leurs inspirations

edit

(requête pas de moi)

SELECT distinct ?planet ?planetLabel ?satellite ?satelliteLabel ?named ?namedLabel ?namedDescription WHERE {
  ?planet wdt:P31/wdt:P279* wd:Q13205267.
  ?satellite wdt:P31/wdt:P279* wd:Q2537.
  ?satellite wdt:P397 ?planet.
  ?satellite wdt:P138 ?named.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?planet p:P2244/psv:P2244 ?statement.
      ?statement wikibase:quantityUnit ?unit.
      ?statement wikibase:quantityAmount ?distance.
      ?statement wikibase:quantityNormalized/wikibase:quantityAmount ?distanceNormalized. # convert to normalized unit (meter)
      BIND (?distanceNormalized / 9460800000000000  AS ?lightyears)
}
ORDER BY ?lightyears
Try it!


Wargames & board wargames

edit
SELECT DISTINCT ?item ?itemLabel ?publisherLabel WHERE {
  ?item wdt:P31*/wdt:P279* wd:Q1501543.
  OPTIONAL { ?item wdt:P123 ?publisher.}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Persons born the same day

edit
SELECT ?item ?articlename ?itemLabel ?itemDescription ?sl
WHERE {
   VALUES ?dod {"+1966-08-25"^^xsd:dateTime}
    ?dod ^wdt:P569 ?item .
    ?item wikibase:sitelinks ?sl .
    ?item ^schema:about ?article .
    ?article schema:isPartOf <https://en.wikipedia.org/>;
    schema:name ?articlename .
  SERVICE wikibase:label
    {
      bd:serviceParam wikibase:language "en" .
      ?item rdfs:label ?itemLabel .
      ?item schema:description ?itemDescription .
    }
  BIND(REPLACE(?itemLabel, "^.*(?<! [Vv][ao]n| [Dd][aeiu]| [Dd][e][lns]| [Ll][ae]) (?!([SJ]r\\.?|[XVI]+)$)", "") AS ?sortname)  
} ORDER BY ASC(UCASE(?sortname)) ASC(UCASE(?itemLabel))
Try it!

Fictional wars

edit

by Martin L Poulter, adapted from Kaitary

#defaultView:Graph
SELECT ?from ?fromLabel ?to ?toLabel ?rgb WHERE {
  {SELECT (?fictional_war AS ?from) (?universe AS ?to) ("F7FF00" as ?rgb) WHERE {
  ?fictional_war wdt:P31 wd:Q17198419. OPTIONAL{?fictional_war wdt:P1080 ?narr_universe}
    OPTIONAL {?fictional_war wdt:P8345 ?franchise }
    OPTIONAL {?fictional_war wdt:P1441 ?work }
    BIND(COALESCE(?narr_universe, ?franchise, ?work, '') AS ?universe)
  } }
UNION {SELECT (?participant AS ?from) (?fictional_war AS ?to) ("7FFF00" as ?rgb) WHERE {
   ?fictional_war wdt:P31 wd:Q17198419.
OPTIONAL { ?fictional_war wdt:P710 ?participant } } }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Tous les LDVELH

edit
SELECT DISTINCT ?item ?itemLabel ?instanceLabel ?formLabel ?genreLabel ?publisherLabel  WHERE {
  ?item (wdt:P31*|wdt:P7937|wdt:P136)/wdt:P279* wd:Q642946.
  OPTIONAL { ?item wdt:P123 ?publisher.}
  OPTIONAL { ?item wdt:P136 ?genre.}
  OPTIONAL { ?item wdt:P31 ?instance.}
  OPTIONAL { ?item wdt:P7937 ?form.}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

Vérifier dans label = Gamebook + instance of = book series