everypolitician / compare_with_wikidata

Library for diffing Wikidata and CSVs
MIT License
2 stars 0 forks source link

Infer Wikidata membership item from legislature in Wikidata #3

Closed chrismytton closed 7 years ago

chrismytton commented 7 years ago

In most cases the legislature's Wikidata ID should be available in the Popolo JSON. We can use this to dynamically look up the Wikidata item that represents a membership in that legislature. This would remove the need to pass in a WIKIDATA_MEMBERSHIP_ITEM option manually.

chrismytton commented 7 years ago

This SPARQL query provided by @tmtmtmtm is a good way of mapping between a legislature and the membership item for that legislature.

SELECT ?membership ?membershipLabel ?legislature ?legislatureLabel WHERE {
  ?membership wdt:P279* wd:Q4175034 ;
              wdt:P361 ?legislature .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
chrismytton commented 7 years ago

Also worth noting that the connection between Wikidata legislatures item and the membership of legislature item might not always be done in a consistent way, but this is something we should tidy up as needed.

chrismytton commented 7 years ago

Pull request for this is here: https://github.com/everypolitician/compare_morph_to_wikidata/pull/5, but before that gets merged I'm going to fix https://github.com/everypolitician/everypolitician-popolo/issues/110 to make the code for that a bit cleaner.

chrismytton commented 7 years ago

We've decided that until we have a better idea of some common patterns we don't want to be generating SPARQL queries. For the time being we're going to force the user to provide their own SPARQL query, which has been done in https://github.com/everypolitician/compare_with_wikidata/pull/9.