query-a5de8b61f2ee50f56225e2917f66f5bd

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?siège ?siègeLabel ?dur_e ?unitLabel ?duréeNorm WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
{  ?siège wdt:P31 wd:Q188055.
   ?siège wdt:P2047 ?dur_e. 
   ?siège p:P2047/psv:P2047/wikibase:quantityUnit ?unit. 
   ?siège p:P2047/psn:P2047/wikibase:quantityAmount ?duréeNorm . # this section finds only periods which can be normalised - everything except months
 }
  union
{  ?siège wdt:P31 wd:Q188055.
   ?siège wdt:P2047 ?dur_e. 
   ?siège p:P2047/psv:P2047/wikibase:quantityUnit ?unit. 
   ?siège p:P2047/psv:P2047/wikibase:quantityUnit wd:Q5151. # force this bit to only do months
   bind((?dur_e*30*86400) as ?duréeNorm) } # normalised length = months * 30 * 86400
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?dur_e"):::projected v5("?duréeNorm"):::projected v1("?siège"):::projected v3("?unit") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) c13(["wd:Q5151"]):::iri c2(["bd:serviceParam"]):::iri c6(["wd:Q188055"]):::iri c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c6 v1 --"p:direct/P2047"--> v2 v1 --"p:P2047"--> a5 a5 --"p:statement/value/P2047"--> a6 a6 --"wikibase:quantityUnit"--> v3 v1 --"p:P2047"--> a7 a7 --"p:statement/value/P2047"--> a8 a8 --"wikibase:quantityUnit"--> c13 bind0[/"?dur_e * '30^^xsd:integer' * '86400^^xsd:integer'"/] v2 --o bind0 bind0 --as--o v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c6 v1 --"p:direct/P2047"--> v2 v1 --"p:P2047"--> a1 a1 --"p:statement/value/P2047"--> a2 a2 --"wikibase:quantityUnit"--> v3 v1 --"p:P2047"--> a3 a3 --"p:statement/value-normalized/P2047"--> a4 a4 --"wikibase:quantityAmount"--> v5 end union0r <== or ==> union0l end