« WikiLex:Exemples de requêtes » : différence entre les versions

De WikiLex
Aller à la navigation Aller à la recherche
 
(9 versions intermédiaires par le même utilisateur non affichées)
Ligne 35 : Ligne 35 :
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>


SELECT ?Nature (COUNT(?item) AS ?Quantité)
SELECT ?nature (COUNT(?item) AS ?quantité)
WHERE {
WHERE {
   {
   {
     ?item wlt:P1 ?nature .
     ?item wlt:P1 [ wlt:P2 wl:Q2 ; rdfs:label ?nature ] .
    ?nature rdfs:label ?Nature .
     FILTER(LANG(?nature) = "fr") .
     FILTER(LANG(?Nature) = "fr") .
   }
   }
   UNION
   UNION
   {
   {
     ?item wlt:P1 ?nature .
     ?item wlt:P1 [ wlt:P2 wl:Q2 ] .
     BIND("Total"@fr AS ?Nature) .
     BIND("Total"@fr AS ?nature) .
   }
   }
}
}
GROUP BY ?Nature
GROUP BY ?nature
ORDER BY DESC(?Quantité)
ORDER BY DESC(?quantité)
}}
}}


Ligne 65 : Ligne 64 :
SELECT ?natureLegislative (STR(?annee) AS ?Année) (COUNT(?loi) AS ?Quantité) ?natureLegislativeLabel
SELECT ?natureLegislative (STR(?annee) AS ?Année) (COUNT(?loi) AS ?Quantité) ?natureLegislativeLabel
WHERE {
WHERE {
   VALUES ?natureLegislative {wl:Q13 wl:Q14 wl:Q15 wl:Q16 wl:Q17 wl:Q18 wl:19}
   VALUES ?natureLegislative {wl:Q13 wl:Q14 wl:Q15 wl:Q16 wl:Q17 wl:Q18 wl:Q19}
   ?loi wlt:P1 ?natureLegislative .
   ?loi wlt:P1 ?natureLegislative .
   ?loi wlt:P27 ?date_texte .
   ?loi wlt:P27 ?date_texte .
Ligne 192 : Ligne 191 :
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>


SELECT ?item ?itemLabel ?date_texte ?vigueurLabel
SELECT ?item ?itemLabel ?numero ?date_texte ?vigueurLabel ?jorftext ?legitext
WHERE {
WHERE {
   ?item wlt:P1 wl:Q13 .
   ?item wlt:P1 wl:Q13 .
  OPTIONAL { ?item wlt:P18 ?numero } .
   OPTIONAL { ?item wlt:P27 ?date_texte } .
   OPTIONAL { ?item wlt:P27 ?date_texte } .
   OPTIONAL { ?item wlt:P39 ?vigueur } .
   OPTIONAL { ?item wlt:P39 ?vigueur } .
  OPTIONAL { ?item wlt:P19 ?jorftext } .
  OPTIONAL { ?item wlt:P20 ?legitext } .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
}
ORDER BY DESC(?date_texte)
ORDER BY ?date_texte
}}
}}


Ligne 253 : Ligne 255 :
}}
}}


== Correspondances WikiLex ↔ Wikidata ==
== Correspondances vie-publique.fr ↔ WikiLex ↔ Wikidata ==
 
Avancement en cours pour les correspondances Wikidata : [[WikiLex:Wikidata]]


{{SPARQL|query=
{{SPARQL|query=
Ligne 260 : Ligne 264 :
PREFIX wltn: <http://wikilex.seb35.fr/prop/direct-normalized/>
PREFIX wltn: <http://wikilex.seb35.fr/prop/direct-normalized/>


SELECT ?item ?itemLabel ?itemWikidata
SELECT DISTINCT ?item ?itemLabel ?viepublique ?wikidata
WHERE {
WHERE {
   ?item wlt:P1 [ wlt:P2 wl:Q2 ] .
   ?item wlt:P1 [ wlt:P2 wl:Q2 ] ; rdfs:label ?itemLabel FILTER( LANG( ?itemLabel ) = "fr" ) .
  ?item wltn:P3 ?itemWikidata .
   OPTIONAL { ?item wlt:P27 ?date } .
   OPTIONAL { ?item wlt:P27 ?date } .
   OPTIONAL { ?item rdfs:label ?itemLabel FILTER(LANG(?itemLabel) = "fr") }
 
   { ?item wlt:P24 ?viepublique OPTIONAL { ?item wltn:P3 ?wikidata } }
  UNION { ?item wltn:P3 ?wikidata OPTIONAL { ?item wlt:P24 ?viepublique } } .
}
ORDER BY ?date ?itemLabel
}}
 
== Déclarations officielles marquées comme erreur ==
 
Ces déclarations provenant de la base LEGI (officielle) ont été annotées par des humains comme des erreurs, voir [[WikiLex:Contribution]].
 
{{SPARQL|query=
PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlpr: <http://wikilex.seb35.fr/prop/reference/>
 
SELECT ?s ?pt ?v
WHERE {
  [] rdf:type wikibase:Property ;
    wikibase:claim ?pp ;
    wikibase:directClaim ?pt ;
    wikibase:statementProperty ?pps ;
    wikibase:novalue ?pno .
 
  ?s ?pp ?statement .
  ?statement wikibase:rank wikibase:DeprecatedRank .
  { ?statement ?pps ?v } UNION { ?statement rdf:type ?pno } .
  ?statement prov:wasDerivedFrom [
    wlpr:P10 wl:Q22
  ]
}
LIMIT 100
}}
 
== Exploration des ajouts d’un import un jour donné ==
 
Noter que les références passées sont écrasées par les références plus récentes. Cette requête a donc plus de valeur sur le dernier import.
 
{{SPARQL|query=
PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
PREFIX wlpr: <http://wikilex.seb35.fr/prop/reference/>
 
SELECT DISTINCT ?item ?wlp ?propertyLabel ?itemLabel
WHERE {
  [] rdf:type wikibase:Property ; wikibase:claim ?wlp ; rdfs:label ?propertyLabel FILTER( LANG( ?propertyLabel ) = "fr" ) .
  ?item wlt:P1 [ wlt:P2 wl:Q2 ] ; rdfs:label ?itemLabel FILTER( LANG( ?itemLabel ) = "fr" ) .
  ?item ?wlp [
      prov:wasDerivedFrom [
        wlpr:P10 wl:Q22 ; wlpr:P11 "2020-01-03"^^xsd:dateTime
      ]
    ]
}
LIMIT 100
}}
 
== Recherche d’un texte selon certains critères (modèle de requête) ==
 
{{SPARQL|query=
PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
 
SELECT ?item ?itemLabel
WHERE {
  ?item wlt:P1 [ wlt:P2 wl:Q2 ] ; rdfs:label ?itemLabel FILTER(LANG(?itemLabel) = "fr") .
 
  #?item wlt:P27 "2005-12-12"^^xsd:dateTime . # date de promulgation
 
  #?item wlt:P19 "JORFTEXT000000317531" . # identifiant JORFTEXT
 
  ?item wlt:P17 "IOCX0903274L" . # NOR
 
  #?item wlt:P18 "46-685" . # numéro de la loi
 
  #?item wlt:P27 ?date . # ces 3 lignes pour afficher toutes les lois d’une année
  #FILTER( ?date >= "1889-01-01"^^xsd:dateTime )
  #FILTER( ?date <= "1889-12-31"^^xsd:dateTime )
}
}
ORDER BY ?date
}}
}}

Dernière version du 16 août 2021 à 13:25

Cette page présente certaines requêtes, par exemple le nombre de lois par année ou la liste des lois organiques.

Si vous souhaitez une requête mais que vous ne connaissez pas le language SPARQL, vous pouvez décrire votre idée sur la page de discussion.

Préfixes

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
PREFIX wltn: <http://wikilex.seb35.fr/prop/direct-normalized/>
PREFIX wlp: <http://wikilex.seb35.fr/prop/>
PREFIX wlps: <http://wikilex.seb35.fr/prop/statement/>
PREFIX wlpsv: <http://wikilex.seb35.fr/prop/statement/value/>
PREFIX wlpsn: <http://wikilex.seb35.fr/prop/statement/value-normalized/>
PREFIX wlpq: <http://wikilex.seb35.fr/prop/qualifier/>
PREFIX wlpqv: <http://wikilex.seb35.fr/prop/qualifier/value/>
PREFIX wlpqn: <http://wikilex.seb35.fr/prop/qualifier/value-normalized/>
PREFIX wlpr: <http://wikilex.seb35.fr/prop/reference/>
PREFIX wlprv: <http://wikilex.seb35.fr/prop/reference/value/>
PREFIX wlprn: <http://wikilex.seb35.fr/prop/reference/value-normalized/>
PREFIX wlno: <http://wikilex.seb35.fr/prop/novalue/>
PREFIX wlref: <http://wikilex.seb35.fr/reference/>
PREFIX wlv: <http://wikilex.seb35.fr/value/>

SELECT *
WHERE {
  
}

Essayez !

Nombre de lois par nature

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?nature (COUNT(?item) AS ?quantité)
WHERE {
  {
    ?item wlt:P1 [ wlt:P2 wl:Q2 ; rdfs:label ?nature ] .
    FILTER(LANG(?nature) = "fr") .
  }
  UNION
  {
    ?item wlt:P1 [ wlt:P2 wl:Q2 ] .
    BIND("Total"@fr AS ?nature) .
  }
}
GROUP BY ?nature
ORDER BY DESC(?quantité)

Essayez !

Évolution du nombre de textes de nature législative

# Évolution du nombre de textes de nature législative
# - par défaut entre 1900 et 2019 inclus
# - il manque des textes dans les temps anciens, mais difficile de savoir combien

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

#defaultView:LineChart
SELECT ?natureLegislative (STR(?annee) AS ?Année) (COUNT(?loi) AS ?Quantité) ?natureLegislativeLabel
WHERE {
  VALUES ?natureLegislative {wl:Q13 wl:Q14 wl:Q15 wl:Q16 wl:Q17 wl:Q18 wl:Q19}
  ?loi wlt:P1 ?natureLegislative .
  ?loi wlt:P27 ?date_texte .
  BIND(YEAR(?date_texte) AS ?annee)
  FILTER(?annee >= 1900 && ?annee <= 2019)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr" } .
}
GROUP BY ?natureLegislative ?annee ?natureLegislativeLabel
ORDER BY ?annee

Essayez !

Évolution du nombre de textes de nature réglementaire

L’ordre de grandeur des textes réglementaires est plus grand que les textes de nature législative, aussi mettre les deux ensembles « tassent » les textes législatifs, les rendant peu visibles.

# Évolution du nombre de textes de nature réglementaire
# - par défaut entre 1900 et 2019 inclus
# - il manque des textes dans les temps anciens, mais difficile de savoir combien

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

#defaultView:LineChart
SELECT ?natureRéglementaire (STR(?annee) AS ?Année) (COUNT(?loi) AS ?Quantité) ?natureRéglementaireLabel
WHERE {
  VALUES ?natureRéglementaire {wl:Q20 wl:Q21}
  ?loi wlt:P1 ?natureRéglementaire .
  ?loi wlt:P27 ?date_texte .
  BIND(YEAR(?date_texte) AS ?annee)
  FILTER(?annee >= 1900 && ?annee <= 2019)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr" } .
}
GROUP BY ?natureRéglementaire ?annee ?natureRéglementaireLabel
ORDER BY ?annee

Essayez !

Nombre de lois par nature et par état

Nature = loi organique, loi, décret…
État = en vigueur, abrogé, périmé…

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?natureLabel ?etatLabel (COUNT(?item) AS ?total)
WHERE {
  VALUES ?etat {wl:Q3 wl:Q6 wl:Q7 wl:Q8 wl:Q9 wl:Q10}
  ?nature wlt:P2 wl:Q2 .
  ?item wlt:P1 ?nature .
  ?item wlt:P39 ?etat .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
GROUP BY ?natureLabel ?etatLabel
ORDER BY ?natureLabel ?etatLabel

Essayez !

Codes

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?vigueurLabel
WHERE {
  ?item wlt:P1 wl:Q17 .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY DESC(?date_texte)

Essayez !

Lois ordinaires

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?date_texte ?vigueurLabel
WHERE {
  ?item wlt:P1 wl:Q16 .
  OPTIONAL { ?item wlt:P27 ?date_texte } .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY DESC(?date_texte)

Essayez !

Lois organiques

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?date_texte ?vigueurLabel
WHERE {
  ?item wlt:P1 wl:Q15 .
  OPTIONAL { ?item wlt:P27 ?date_texte } .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY DESC(?date_texte)

Essayez !

Constitutions

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?date_texte ?vigueurLabel
WHERE {
  ?item wlt:P1 wl:Q14 .
  OPTIONAL { ?item wlt:P27 ?date_texte } .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY DESC(?date_texte)

Essayez !

Lois constitutionnelles

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?numero ?date_texte ?vigueurLabel ?jorftext ?legitext
WHERE {
  ?item wlt:P1 wl:Q13 .
  OPTIONAL { ?item wlt:P18 ?numero } .
  OPTIONAL { ?item wlt:P27 ?date_texte } .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  OPTIONAL { ?item wlt:P19 ?jorftext } .
  OPTIONAL { ?item wlt:P20 ?legitext } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY ?date_texte

Essayez !

Ordonnances

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?date_texte ?vigueurLabel
WHERE {
  ?item wlt:P1 wl:Q19 .
  OPTIONAL { ?item wlt:P27 ?date_texte } .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY DESC(?date_texte)

Essayez !

Décrets-lois

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel ?date_texte ?vigueurLabel
WHERE {
  ?item wlt:P1 wl:Q18 .
  OPTIONAL { ?item wlt:P27 ?date_texte } .
  OPTIONAL { ?item wlt:P39 ?vigueur } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" } .
}
ORDER BY DESC(?date_texte)

Essayez !

Correspondances cid ↔ items Wikibase

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlp: <http://wikilex.seb35.fr/prop/>
PREFIX wlps: <http://wikilex.seb35.fr/prop/statement/>
PREFIX wlpr: <http://wikilex.seb35.fr/prop/reference/>

SELECT ?cid ?item
WHERE {
  ?item wlp:P21 [
      wlps:P21 ?cid ;
      #prov:wasDerivedFrom [
      #  wlpr:P10 wl:Q22
      #]
    ]
}

Essayez !

Correspondances vie-publique.fr ↔ WikiLex ↔ Wikidata

Avancement en cours pour les correspondances Wikidata : WikiLex:Wikidata

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
PREFIX wltn: <http://wikilex.seb35.fr/prop/direct-normalized/>

SELECT DISTINCT ?item ?itemLabel ?viepublique ?wikidata
WHERE {
  ?item wlt:P1 [ wlt:P2 wl:Q2 ] ; rdfs:label ?itemLabel FILTER( LANG( ?itemLabel ) = "fr" ) .
  OPTIONAL { ?item wlt:P27 ?date } .

  { ?item wlt:P24 ?viepublique OPTIONAL { ?item wltn:P3 ?wikidata } }
  UNION { ?item wltn:P3 ?wikidata OPTIONAL { ?item wlt:P24 ?viepublique } } .
}
ORDER BY ?date ?itemLabel

Essayez !

Déclarations officielles marquées comme erreur

Ces déclarations provenant de la base LEGI (officielle) ont été annotées par des humains comme des erreurs, voir WikiLex:Contribution.

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlpr: <http://wikilex.seb35.fr/prop/reference/>

SELECT ?s ?pt ?v
WHERE {
  [] rdf:type wikibase:Property ;
     wikibase:claim ?pp ;
     wikibase:directClaim ?pt ;
     wikibase:statementProperty ?pps ;
     wikibase:novalue ?pno .

  ?s ?pp ?statement .
  ?statement wikibase:rank wikibase:DeprecatedRank .
  { ?statement ?pps ?v } UNION { ?statement rdf:type ?pno } .
  ?statement prov:wasDerivedFrom [
    wlpr:P10 wl:Q22
  ]
}
LIMIT 100

Essayez !

Exploration des ajouts d’un import un jour donné

Noter que les références passées sont écrasées par les références plus récentes. Cette requête a donc plus de valeur sur le dernier import.

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>
PREFIX wlpr: <http://wikilex.seb35.fr/prop/reference/>

SELECT DISTINCT ?item ?wlp ?propertyLabel ?itemLabel
WHERE {
  [] rdf:type wikibase:Property ; wikibase:claim ?wlp ; rdfs:label ?propertyLabel FILTER( LANG( ?propertyLabel ) = "fr" ) .
  ?item wlt:P1 [ wlt:P2 wl:Q2 ] ; rdfs:label ?itemLabel FILTER( LANG( ?itemLabel ) = "fr" ) .
  ?item ?wlp [
      prov:wasDerivedFrom [
        wlpr:P10 wl:Q22 ; wlpr:P11 "2020-01-03"^^xsd:dateTime
      ]
    ]
}
LIMIT 100

Essayez !

Recherche d’un texte selon certains critères (modèle de requête)

PREFIX wl: <http://wikilex.seb35.fr/entity/>
PREFIX wlt: <http://wikilex.seb35.fr/prop/direct/>

SELECT ?item ?itemLabel
WHERE {
  ?item wlt:P1 [ wlt:P2 wl:Q2 ] ; rdfs:label ?itemLabel FILTER(LANG(?itemLabel) = "fr") .
  
  #?item wlt:P27 "2005-12-12"^^xsd:dateTime . # date de promulgation
  
  #?item wlt:P19 "JORFTEXT000000317531" . # identifiant JORFTEXT
  
  ?item wlt:P17 "IOCX0903274L" . # NOR
  
  #?item wlt:P18 "46-685" . # numéro de la loi
  
  #?item wlt:P27 ?date . # ces 3 lignes pour afficher toutes les lois d’une année
  #FILTER( ?date >= "1889-01-01"^^xsd:dateTime )
  #FILTER( ?date <= "1889-12-31"^^xsd:dateTime )
}

Essayez !