Closed chrismytton closed 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". }
}
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.
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.
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.
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.