Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requêtes dans wikidata #1

Open
atterebf opened this issue Mar 8, 2024 · 0 comments
Open

Requêtes dans wikidata #1

atterebf opened this issue Mar 8, 2024 · 0 comments

Comments

@atterebf
Copy link

atterebf commented Mar 8, 2024

Exemple: Pascale Bruderer, https://www.wikidata.org/wiki/Q116100

SPARQL-Enpoint: https://query.wikidata.org/

Positions de politiciens suisses

Noter que dans cette requête on utilise la structure des statements
et on ajoute toutes les propriétés de chaque statement

  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
  
  select distinct ?item ?itemLabel ?itemDescription ?birthDate ?position ?positionLabel ?p ?o
  where {
      ?item wdt:P31 wd:Q5;  # Any instance of a human.
            p:P39 ?statement.
          ?statement ps:P39 wd:Q18510612;
                     ps:P39 ?position;
                     ?p ?o.
      ?item wdt:P569 ?birthDate.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,nl" }
  }
  
  LIMIT 500

Seulement les propriétés liées à la fonction

Noter qu'il y a plein de doublons si différentes valeurs

  SELECT DISTINCT ?item ?itemLabel ?itemDescription ?birthDate ?position ?positionLabel ?startYear ?startTime ?endTime ?p ?o
  where {
      ?item wdt:P31 wd:Q5;  # Any instance of a human.
            p:P39 ?statement.
          ?statement ps:P39 wd:Q18510612;
                     ps:P39 ?position;
                     pq:P580 ?startTime;
                     pq:P582 ?endTime.
      ?item wdt:P569 ?birthDate.
      BIND(REPLACE(str(?startTime), "(.*)([0-9]{4})(.*)", "$2") AS ?startYear)
   
    FILTER (?startYear > '1950')
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  }
  ORDER BY ?startYear
  LIMIT 500
  
  
  
  SELECT DISTINCT ?item ?itemLabel ?itemDescription ?birthYear ?position ?positionLabel ?startYear ?startTime ?endTime
  where {
      ?item wdt:P31 wd:Q5;  # Any instance of a human.
            p:P39 ?statement.
          ?statement ps:P39 wd:Q18510612;
                     ps:P39 ?position;
                     pq:P580 ?startTime;
                     pq:P582 ?endTime.
      ?item wdt:P569 ?birthDate.
      BIND(REPLACE(str(?startTime), "(.*)([0-9]{4})(.*)", "$2") AS ?startYear)
      BIND(REPLACE(str(?birthDate), "(.*)([0-9]{4})(.*)", "$2") AS ?birthYear)
   
    FILTER (?startYear > '1950')
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  }
  ORDER BY ?startYear
  LIMIT 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant