Requêtes DBpedia pour importer dans la base de données SQL - projhistoire/Projet-Histoire GitHub Wiki

Requête de la liste d'astronautes à importer depuis DBpedia

PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (?o1 AS ?subject_uri) ?birthYear
#(COUNT(*) AS ?effectif)
WHERE {
SELECT DISTINCT ?o1 ?birthYear ?target (str(?label) as ?name)
WHERE {
   {
       {dbr:List_of_astronauts_by_name ?p ?o1.}
   UNION
       {dbr:List_of_physicists ?p ?o1.}
   UNION
       {?o1 ?p dbr:physicists.}
   UNION
       {?o1 ?p dbr:astronaut.}
   UNION
       {?o1 ?p dbr:biologist.}
   }
   ?o1 a dbo:Person;
   dbp:birthDate | dbo:birthDate ?birthDate;
   dbp:occupation | dbo:occupation ?target.
?target rdfs:label ?label.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
   FILTER ( (?birthYear >= 1934   )  && LANG(?label) = 'en') #  && ?birthYear < 2007
       }
ORDER BY ?birthYear
}

Requête de la liste des occupations à importer

PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT (?o1 AS ?subject_uri) (dbo:occupation AS ?property_uri) (?target AS ?object_uri) (?name AS ?label)
WHERE {
  SELECT DISTINCT ?o1 ?target (str(?label) AS ?name)
  WHERE {
    {
      dbr:List_of_astronauts_by_name ?p ?o1.
    }
    ?o1 a dbo:Person;
        dbp:birthDate | dbo:birthDate ?birthDate;
        dbp:occupation | dbo:occupation ?target.
    ?target rdfs:label ?label.
    BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
    FILTER (?birthYear >= 1934 && LANG(?label) = 'en')
  }
  ORDER BY ?birthYear
}



Requête des nationalités de la liste d'astronautes

PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (?o1 AS ?subject_uri) ?birthYear ?country ?nationality
WHERE {
SELECT DISTINCT ?o1 ?birthYear ?country ?nationality
WHERE { 
    {
        {dbr:List_of_astronauts_by_name ?p ?o1.}
      UNION
          {dbr:List_of_physicists ?p ?o1.}
      UNION
          {?o1 ?p dbr:physicists.}
      UNION
          {?o1 ?p dbr:astronauts.}
      UNION
          {?o1 ?p dbr:biologists.}
    
    }
    ?o1 a dbo:Person;
    dbp:birthDate | dbo:birthDate ?birthDate.
OPTIONAL {
?o1 dbo:birthPlace ?birthPlace.
?birthPlace a dbo:Country.
}
BIND(STRAFTER(STR(?birthPlace), 'http://dbpedia.org/resource/') as ?country)
OPTIONAL {
?o1 dbo:nationality|dbp:nationality ?mixedNationality.
}
BIND(IF(
    STRSTARTS(STR(?mixedNationality), 'http://dbpedia.org/resource/'), 
    STRAFTER(STR(?mixedNationality), 'http://dbpedia.org/resource/'), 
    STR(?mixedNationality)
) as ?nationality)
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
    FILTER ( (?birthYear >= 1934   )) 
        }
ORDER BY ?birthYear
}