query-18b98ad4080d506dcbe7a4bd218a28f8

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?code WHERE {
  { ?item wdt:P31 wd:Q1426271 } UNION { ?item wdt:P16 wd:Q1426271 } . 
  MINUS { VALUES ?outre_mer { wd:Q17012 wd:Q17054 wd:Q3769 wd:Q17070 wd:Q34617 wd:Q17063 wd:Q25362 wd:Q126125 } . ?item wdt:P131 ?outre_mer } . 
  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) 
  BIND(REPLACE(str(?item),"http://www.wikidata.org/entity/","") as ?wd_item)
  BIND(IF(?statut="N","RN ",IF(?statut="F","RF ","")) as ?statut2)
  BIND(CONCAT("* [[",?wd_item,"|",?statut2,?numero,"]]") as ?code)
  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; v15("?cledetri") v17("?code"):::projected v2("?item") v9("?longnum") v12("?longnumsp") v5("?longp1824") v13("?longprefixe") v8("?num") v7("?numero") v11("?numsp") v10("?numz") v3("?outre_mer") v4("?p1824") v14("?prefixe") v6("?statut") v16("?statut2") v15("?wd_item") c7(["bd:serviceParam"]):::iri c2(["wd:Q1426271"]):::iri c9(["fr"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P16"--> c2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P31"--> c2 end union0r <== or ==> union0l end subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; bind1[/VALUES ?outre_mer/] bind1-->v3 bind10(["wd:Q17012"]) bind10 --> bind1 bind11(["wd:Q17054"]) bind11 --> bind1 bind12(["wd:Q3769"]) bind12 --> bind1 bind13(["wd:Q17070"]) bind13 --> bind1 bind14(["wd:Q34617"]) bind14 --> bind1 bind15(["wd:Q17063"]) bind15 --> bind1 bind16(["wd:Q25362"]) bind16 --> bind1 bind17(["wd:Q126125"]) bind17 --> bind1 v2 --"wdt:P131"--> v3 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P1824".-> v4 end bind2[/"string-length(str(?p1824))"/] v4 --o bind2 bind2 --as--o v5 bind3[/"substring(str(?p1824),'1^^xsd:integer','1^^xsd:integer')"/] v4 --o bind3 bind3 --as--o v6 bind4[/"substring(str(?p1824),'2^^xsd:integer',?longp1824 - '1^^xsd:integer')"/] v4 --o bind4 v5 --o bind4 bind4 --as--o v7 bind5[/"replace(substring(str(?numero),'1^^xsd:integer','4^^xsd:integer'),'#91;A-Za-z #93;','')"/] v7 --o bind5 bind5 --as--o v8 bind6[/"string-length(str(?num))"/] v8 --o bind6 bind6 --as--o v9 bind7[/"concat(if(?longnum = '1^^xsd:integer','000',if(?longnum = '2^^xsd:integer','00',if(?longnum = '3^^xsd:integer','0',''))),str(?num))"/] v9 --o bind7 v8 --o bind7 bind7 --as--o v10 bind8[/"concat(str(?statut),str(?num))"/] v6 --o bind8 v8 --o bind8 bind8 --as--o v11 bind9[/"string-length(str(?numsp))"/] v11 --o bind9 bind9 --as--o v12 bind10[/"?longp1824 - ?longnumsp"/] v5 --o bind10 v12 --o bind10 bind10 --as--o v13 bind11[/"substring(str(?p1824),?longnumsp + '1^^xsd:integer',?longprefixe)"/] v4 --o bind11 v12 --o bind11 v13 --o bind11 bind11 --as--o v14 bind12[/"concat(str(?statut),str(?numz),str(?prefixe))"/] v6 --o bind12 v10 --o bind12 v14 --o bind12 bind12 --as--o v15 bind13[/"replace(str(?item),'http://www.wikidata.org/entity/','')"/] v2 --o bind13 bind13 --as--o v15 bind14[/"if(?statut = 'N','RN ',if(?statut = 'F','RF ',''))"/] v6 --o bind14 bind14 --as--o v16 bind15[/"concat('* #91;#91;',?wd_item,'|',?statut2,?numero,'#93;#93;')"/] v15 --o bind15 v16 --o bind15 v7 --o bind15 bind15 --as--o v17 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end