albertvillanova / WikidataBot

Wikidata bot
http://www.wikidata.org/wiki/User:AVMbot
0 stars 0 forks source link

[scripts] Multiple INSEE codes #11

Open albertvillanova opened 4 years ago

albertvillanova commented 4 years ago

While adding population to cantons, 2 of them gave error:

ERROR: to_population_value does not contain INSSE code: 6261 : Q1617540 : canton d'Outreau
ERROR: to_population_value does not contain INSSE code: 6273 : Q1725198 : canton de Douvrin

due to the fact that these 2 cantons have multiple INSEE codes.

albertvillanova commented 4 years ago

These 2 cantons changed its INSEE code in 2015:

Current implementation of the script to get the INSEE code:

TODO:

albertvillanova commented 4 years ago

There are 4 cantons with multiple INSEE codes:

# Cantons with INSEE code with end_time
SELECT ?item ?label_ca ?label_fr ?insee_end_time_date ?insee_code
WHERE {
  ?item p:P31 ?st .  # instance_of
  ?st ps:P31 wd:Q18524218 .  # canton_of_france_from_2015    # Q484170 .  # commune_of_france   

  OPTIONAL{?st pq:P580 ?start_time_date}
  FILTER(IF(BOUND(?start_time_date), ?start_time_date <= "2019-01-01"^^xsd:dateTime, true))

  OPTIONAL{?st pq:P582 ?end_time_date}
  FILTER(IF(BOUND(?end_time_date), ?end_time_date > "2019-01-01"^^xsd:dateTime, true))

  ?item p:P2506 ?st_insee .  # insee_canton_code
  ?st_insee ps:P2506 ?insee_code .

  ?st_insee pq:P582 ?insee_end_time_date

  OPTIONAL{ ?item rdfs:label ?label_ca filter (lang(?label_ca) = "ca"). }
  OPTIONAL{ ?item rdfs:label ?label_fr filter (lang(?label_fr) = "fr"). }
}
LIMIT 10
albertvillanova commented 4 years ago

There are cantons with multiple INSEE codes without end_time:

albertvillanova commented 4 years ago

As first solution, I have updated current INSEE code rank to preferred.