query-04b4be85a757fcd1b15054d6bc47be7b
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?wpfr ?deps WHERE {
{
SELECT DISTINCT ?item (GROUP_CONCAT(DISTINCT ?l; separator = ', ') as ?deps) (COUNT(DISTINCT ?l) as ?count) WHERE {
?item wdt:P16 wd:Q1426271 .
MINUS { ?item wdt:P131 wd:Q17012 } MINUS { ?item wdt:P131 wd:Q17054 } MINUS { ?item wdt:P131 wd:Q3769 } MINUS { ?item wdt:P131 wd:Q17070 } MINUS { ?item wdt:P131 wd:Q34617 } MINUS { ?item wdt:P131 wd:Q17063 } MINUS { ?item wdt:P131 wd:Q25362 } MINUS { ?item wdt:P131 wd:Q126125 } .
?item p:P131/ps:P131 ?dep .
OPTIONAL { ?dep rdfs:label ?l filter (lang(?l) = "fr") }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . }
}
GROUP BY ?item
} .
OPTIONAL { ?wpfr schema:about ?item ; schema:inLanguage "fr" ; schema:isPartOf <https://fr.wikipedia.org/> } .
OPTIONAL { ?item wdt:P1824 ?p1824 }
BIND(STRLEN(str(?p1824)) as ?longp1824)
BIND(SUBSTR(str(?p1824),1,1) as ?statut)
BIND(SUBSTR(str(?p1824),2,(?longp1824 - 1)) as ?numero)
BIND(REPLACE(SUBSTR(str(?numero),1,4),"[A-Za-z ]","") as ?num)
BIND(STRLEN(str(?num)) as ?longnum)
BIND(CONCAT(IF(?longnum=1,"000",IF(?longnum=2,"00",IF(?longnum=3,"0",""))), str(?num)) as ?numz)
BIND(CONCAT(str(?statut),str(?num)) as ?numsp) BIND(STRLEN(str(?numsp)) as ?longnumsp)
BIND((?longp1824 - ?longnumsp) as ?longprefixe) BIND(SUBSTR(str(?p1824),(?longnumsp + 1),?longprefixe) as ?prefixe)
BIND(CONCAT(str(?statut),str(?numz),str(?prefixe)) as ?cledetri)
FILTER(?count=1)
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . }
} ORDER BY ?cledetri
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v19("?cledetri")
v7("?count")
v5("?dep")
v6("?deps"):::projected
v4("?item"):::projected
v3("?l")
v13("?longnum")
v16("?longnumsp")
v9("?longp1824")
v17("?longprefixe")
v12("?num")
v11("?numero")
v15("?numsp")
v14("?numz")
v8("?p1824")
v18("?prefixe")
v10("?statut")
v7("?wpfr"):::projected
a1((" "))
c8(["wd:Q3769"]):::iri
c9(["wd:Q17070"]):::iri
c13(["wd:Q126125"]):::iri
c10(["wd:Q34617"]):::iri
c11(["wd:Q17063"]):::iri
c4(["wd:Q1426271"]):::iri
c7(["wd:Q17054"]):::iri
c12(["wd:Q25362"]):::iri
c23([https://fr.wikipedia.org/]):::iri
c2(["fr"]):::literal
c18(["bd:serviceParam"]):::iri
c6(["wd:Q17012"]):::iri
f0[["?count = '1^^xsd:integer'"]]
f0 --> v7
v4 --"p:direct/P16"--> c4
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c6
end
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c7
end
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c8
end
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c9
end
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c10
end
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c11
end
subgraph minus7["MINUS"]
style minus7 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c12
end
subgraph minus8["MINUS"]
style minus8 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P131"--> c13
end
v4 --"p:P131"--> a1
a1 --"p:statement/P131"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."rdfs:label".-> v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c18 --"wikibase:language"--> c2
end
bind11[/"?l"/]
v3 --o bind11
bind11 --as--o v6
bind12[/"count(?l)"/]
v3 --o bind12
bind12 --as--o v7
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v7 -."schema:about".-> v4
v7 --"schema:inLanguage"--> c2
v7 --"schema:isPartOf"--> c23
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P1824".-> v8
end
bind13[/"string-length(str(?p1824))"/]
v8 --o bind13
bind13 --as--o v9
bind14[/"substring(str(?p1824),'1^^xsd:integer','1^^xsd:integer')"/]
v8 --o bind14
bind14 --as--o v10
bind15[/"substring(str(?p1824),'2^^xsd:integer',?longp1824 - '1^^xsd:integer')"/]
v8 --o bind15
v9 --o bind15
bind15 --as--o v11
bind16[/"replace(substring(str(?numero),'1^^xsd:integer','4^^xsd:integer'),'#91;A-Za-z #93;','')"/]
v11 --o bind16
bind16 --as--o v12
bind17[/"string-length(str(?num))"/]
v12 --o bind17
bind17 --as--o v13
bind18[/"concat(if(?longnum = '1^^xsd:integer','000',if(?longnum = '2^^xsd:integer','00',if(?longnum = '3^^xsd:integer','0',''))),str(?num))"/]
v13 --o bind18
v12 --o bind18
bind18 --as--o v14
bind19[/"concat(str(?statut),str(?num))"/]
v10 --o bind19
v12 --o bind19
bind19 --as--o v15
bind20[/"string-length(str(?numsp))"/]
v15 --o bind20
bind20 --as--o v16
bind21[/"?longp1824 - ?longnumsp"/]
v9 --o bind21
v16 --o bind21
bind21 --as--o v17
bind22[/"substring(str(?p1824),?longnumsp + '1^^xsd:integer',?longprefixe)"/]
v8 --o bind22
v16 --o bind22
v17 --o bind22
bind22 --as--o v18
bind23[/"concat(str(?statut),str(?numz),str(?prefixe))"/]
v10 --o bind23
v14 --o bind23
v18 --o bind23
bind23 --as--o v19
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c18 --"wikibase:language"--> c2
end