query-ff84f11328b3a8e391f2b09a58af3708

rq turtle/ttl

) Edit group 1551435808033, minus the above query, and some manual tweaking to remove some list pages, gives us an extra 335 people (Category:Members_of_the_Dewan_RakyatEventually it would be good to have full rich membership data there, with details of all the individual mandates etc., but for now it would be a little more useful to me if everyone who has been a member had even a bare P39:Q21290861. So Petscan to the rescue again. Enwiki's . I'm always theoretically aware that I should really be using the p:P39/ps:P39 format rather than wdt:P39, for exactly this reason, but in practice I often forget to. For something like this it doesn't really matter, as QuickStatements does the right thing (I could have simply supplied everyone in the Category, without pre-filtering the people who already had a P39: that was just to speed things up a little), but it's a nice reminder of the wider issue with wdt: and Preferred P39s.Preferred statement is marked as (Q862559)Prime Minister of Malaysia statement, but doesn't get returned by the above SPARQL, as his (Q21290861)Member of the Dewan Rakyat already had a (Q181383)Mahathir Mohamad Update: one of the additions failed, which surprised me initially as I'd explicitly removed everyone who already had such a statement. Of course, this could have been a race condition, where someone else added a P39 in between generating the statements to add, and actually adding them, but it turned out to be something a little more interesting. http://www.caribbeanelections.com/ai/elections/default.asp, which makes it trivial to insert a date if it's prominent in a linked Wikipedia article (yes, sourcing from Wikipedia isn't ideal, and the tool doesn't add any references, but this way I can add the information super-quickly, and I'm firmly in "better than nothing" camp). But sometimes Wikipedia doesn't have dates either. This seems to be particularly true for the smaller island nations and territories. Today I had to go looking for several dates for elections in Anguilla, and, as is often the case, the Caribbean Elections site had exactly what I needed: my customised version of Wikidata UsefulsWikidata only has year-precision dates for lots of elections. I've been gradually replacing lots of those as I come across them — usually via (Q21296004)Member of the National Assembly of Togo :(P39)position held , and (Q945)Togo :(P1001)applies to jurisdiction , (Q945)Togo :(P17)country takes care of making sure they all have Edit group 1551440987648Next on the tidying on national legislative elections: Togo. ) (P1001)applies to jurisdiction everywhere instead of (P1011)excluding which fixes a stupid typo where I set Edit Group 1551442416766 (and (Q813)Kyrgyzstan which does likewise for Edit Group 1551442329063Swiftly followed by on both of those! Clearly a sign that it's time for lunch… (P541)office contested instead of (P39)position held for stupidly using fixes moreAnd then , the presidential and parliamentary elections even had entirely separate election dates. I do this often enough that it's mildly annoying how much work it is, but not quite often enough that I've actively gone looking for ways to make it simpler. Maybe I need to batch them up better, so that I do many more in a row, and see if I can spot some common patterns with ways to improve… (Q3586586)1995 Haitian general election , etc), so splitting them up is usually a good idea, anyway, but often it turns out some Wikipedias also have separate items for them, so it's definitely needed (and also leads to the fun of trying to unpick the sitelinks for each language). In one of today's examples ((P1868)ballots cast , (P1697)total valid votes , as well as separate values for each of the vote count properties ((P991)successful candidate and (P541)office contested A task I do a lot, but don't have any tricks for automating, or even making a little bit simpler, is to split an item for an election, when it's really about multiple different elections. This usually ends up with at leat three: one for the "general election", or grouping (which often has a combined article in at leat one Wikipedia), and one each for, say, the presidential election, and the legislative election (sometimes it'll also include local elections or various other combinations). Each of these will end up with a different Edit Group 1551450610481 in (Q21328583)Member of the House of Representatives of Morocco : (P541)office contested , and (Q1028)Morocco : (P1001)applies to jurisdiction , (Q1028)Morocco : (P17)country since 1956 have (Q22342153)Moroccan parliamentary election Hopefully I've got the correct Petscan commands this time: ensuring all instances of . Edit Group 1551452779801 in (Q869)Thailand Then similar for : (Q13217683)United States senator gets a (P541)office contested , etc. Yesterday I tidied up lots of the entries for the House; today it's the turn of the Senate. The main change is to make sure that anything without a (Q7891380)2002 United States Senate election in Alaska , (Q7891368)2002 United States Senate election in Alabama but (Q2647277)2008 United States Senate elections There are lots and lots of Wikidata items relating to elections to the US Congress, as they tend to have individual items for each state — e.g. not only

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q40231.
  ?item rdfs:label ?name.
  FILTER((LANG(?name)) = "en")
  FILTER(CONTAINS(LCASE(?name), LCASE("United States Senate election")))
  FILTER NOT EXISTS { ?item wdt:P541 [] } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v2("?name") a1((" ")) c8(["bd:serviceParam"]):::iri c5(["wd:Q40231"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P541"--> e0a1 e0v1("?item"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> a1 v1 --"wdt:P541"--> a1 f1[["contains(lower-case(?name),lower-case('United States Senate election'))"]] f1 --> v2 f2[["?name = 'en'"]] f2 --> v2 v1 --"wdt:P31"--> c5 v1 --"rdfs:label"--> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end