Wikidata talk:WikiProject every politician/Sweden

From Wikidata
Jump to navigation Jump to search

I am not sure that terms are of good use for Sweden. It seems we don't have any articles about these in Wikipedia and neither have I heard this being talked about either. Anyone else with good insights? Ainali (talk) 21:22, 23 November 2017 (UTC)[reply]

In Sweden I believe a legislative terms is referred to an "electoral period" — e.g. on http://www.riksdagen.se/en/members-and-parties/, it refers in the lead paragraph to "the 2014-2018 electoral period" and on https://www.riksdagen.se/en/How-the-Riksdag-works/Democracy/The-history-of-the-Riksdag/ refers to the extension of the electoral period from three years to four years in 1994. Swedish Wikipedia seems to refer to these as "mandatperioden" (e.g. on https://sv.wikipedia.org/wiki/Riksdagsvalet_i_Sverige_2018 or https://sv.wikipedia.org/wiki/Riksdagsvalet_i_Sverige_2014)
One of the benefits of splitting memberships like this is that each position held (P39) can then have a distinct elected in (P2715) as well, and it becomes significantly easier to produce statistics about each of these periods — e.g. to show how the parties have fared over time, or how gender breakdown or average age or the like has changed. --Oravrattas (talk) 10:04, 24 November 2017 (UTC)[reply]
This template maybe is a start Svenska_riksdagar - Salgo60 (talk) 03:58, 27 November 2017 (UTC)[reply]
@Salgo60: No, since that template has no correlation at all with the electoral periods. It includes every "verksamhetsår" for the riksdag. Ainali (talk) 21:47, 27 November 2017 (UTC)[reply]

Interested

[edit]

When I have finished the connection of P3217 Swedish National Biography(SBL) I am more than interested to learn this. In SBL politicians are a rather big part of the 7000 profiles and I feel the Swedish National Archive has solved the problem a little bit too easy and call everyone part of the parlament and not make a difference between timeperiods...

List of what we find in P39 Position held for profiles with P3217 - query

- Salgo60 (talk) 03:54, 27 November 2017 (UTC)[reply]

Good presentation of "Riksdagstrycket"

[edit]

Video Lotta Åberg Brorsson presenting Riksdagstrycket

This is a presentation filmed with my Iphone. Target group people doing genealogy and try to find "relatives" in the books - Salgo60 (talk) 05:13, 5 September 2018 (UTC)[reply]

Involvement outside Wikimedia

[edit]

Perhaps not contributing many actual new participants currently (I saw User:Ainali in their chat), but for completeness I wanted to mention I noticed a reference here over at CivicTechSweden/Polidata . They describe a whole lot of interesting initiatives. It's interesting, this thing with external groups defining initiatives towards wikimedia (Guerrilla Skepticism on Wikipedia (rationalwiki) come to mind), anyone have enlightening comments on that topic? -- CarlJohanSveningsson (talk) 12:39, 30 November 2019 (UTC)[reply]

Well, I guess that is perhaps not even external groups. I mean, most of the people there are already proponents of citizen engagement and free licenses so I woudn't be surprised if they were casual editors as well Ainali (talk) 17:36, 30 November 2019 (UTC)[reply]

Label/Etikett in Swedish(Svenska) "WikiProject varje politiker" for Q58484874

[edit]

Sorry about the mixed Swedish and English. Jag redigerar WikiProject Politics (Q58484874) och för svenska 'etikett' delen av WikiProjektet(för Sverige) har jag valt "WikiProjekt varje politiker". Om du kan tänka dig ett mer relevant namn, t.ex 'WikiProjekt alla politiker' så varsågod och ändra. Beskrivningen som jag la till temporärt "kollaborativt Wikimedia projekt vars syfte är att kartlägga många politiker i Sverige" kan ni ändra på samma vis. Seeitinmusic (talk) 23:02, 6 January 2020 (UTC)[reply]

Första/andra kammaren

[edit]

Hi, I just found this project and thought I'd just mention that I've been working with adding position held (P39) = member of the First Chamber (Q33071890) to a bunch of politicians from 1867 and forward, along with start and end times and electoral districts. In cases where the politician already was registered as a member of the Swedish parliament, I replaced that property with the more detailed Member of the Första Kammaren. Popperipopp (talk) 16:00, 13 January 2020 (UTC)[reply]

leave of absence for minister assignment

[edit]

I created entering government (Q96349763) to model cases where a member of parliament becomes a minister in the goverment and temporarily give up their seat in parliament. I added it to Gustav Fridolin (Q2029325) as the qualifier value of end cause (P1534). Any feedback is most welcome. Popperipopp (talk) 09:34, 17 June 2020 (UTC)[reply]

@Popperipopp: Might entering government (Q51188211) be sufficient for this? --Oravrattas (talk) 11:29, 18 June 2020 (UTC)[reply]
Ah, I had a feeling something like that existed. Thanks! I suppose it's best to merge entering government (Q96349763) into entering government (Q51188211). Popperipopp (talk) 11:58, 18 June 2020 (UTC)[reply]
Yeah, probably best. I've switched the one person using this to entering government (Q51188211) and then merged them. --Oravrattas (talk) 09:13, 20 June 2020 (UTC)[reply]

Small bot to add basic data for MPs

[edit]

I've written the foundation for a small bot that adds basic information to members of parliament which have position held (P39) -> member of the Swedish Riksdag (Q10655178) but without qualifiers or references. The bot reads a CSV file from data.riksdagen.se and updates the statements with basic qualifiers and references. There's about ~1500 statements that could be added this way. I have one remaining problem (this is my first Wikidata-bot): the program works without references, but when I add them I get an error saying "WDString object cannot be iterated" or something like that. Any ideas? Also, I'm not sure if this is the best place to share the code, but I'll give it a try :) Any feedback is welcome. Popperipopp (talk) 16:03, 22 June 2020 (UTC)[reply]

import time
from datetime import datetime

import requests
import pandas as pd
from wikidataintegrator import wdi_core, wdi_login

WD_USERNAME = 'USER_NAME'
WD_PASSWORD = 'PASSWORD'
RAW_DATA_PATH = 'PATH_OR_URL_TO_FILE'
BOT_SUMMARY = 'Adding position member of Swedish parliament'

# Read and clean input data
# Original file located here: http://data.riksdagen.se/dataset/person/person.csv.zip
df = pd.read_csv(RAW_DATA_PATH, dtype={'Id': str})
df = df[df.Uppdragsroll.isin(['Riksdagsledamot', 'Statsrådsersättare', 'Ersättare'])]
df = df[df.Uppdragsrollstatus.notna()]
df = df[~df.Uppdragsrollstatus.str.contains('Ledig')]
df = df[['Id', 'From', 'Tom', 'Parti', 'Valkrets']]
df = df.sort_values('Id')
df = df[df.Id.notna()]
df = df.dropna()
df = df[df.Parti != '-']

# Get all MPs without qualifiers for the position statements
query = """SELECT ?item ?code
WHERE {
  ?item p:P39 ?positionStatement .
  ?positionStatement ps:P39 ?position .
  ?position wdt:P31* wd:Q10655178 .
  ?item wdt:P1214 ?code .
  
  FILTER NOT EXISTS { ?positionStatement pq:P580 ?start . }
  FILTER NOT EXISTS { ?positionStatement pq:P582 ?end . }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}"""

wd = wdi_core.WDItemEngine.execute_sparql_query(query, as_dataframe=True)
wd.item = wd.item.str.split('/', expand=True)[4]

# Inner join the two dataframes
df = df.merge(wd, left_on='Id', right_on='code', how='inner')
df = df.drop(['Id'], axis=1)

df.Parti = df.Parti.map({
    'L': 'Q110857',
    'SD': 'Q504069',
    'FP': 'Q110857',
    'M': 'Q110843',
    'S': 'Q105112',
    'C': 'Q110832',
    'V': 'Q110837',
    'MP': 'Q213451',
    'KD': 'Q213654'
})

df.Valkrets = df.Valkrets.map({
    'Värmlands län': 'Q10717663',
    'Västra Götalands läns norra': 'Q10718251',
    'Stockholms kommun': 'Q10680603',
    'Västerbottens län': 'Q10717881',
    'Skåne läns västra': 'Q10671087',
    'Dalarnas län': 'Q10466068',
    'Skåne läns norra och östra': 'Q10671085',
    'Västra Götalands läns västra': 'Q10718253',
    'Kronobergs län': 'Q10549465',
    'Stockholms län': 'Q10680613',
    'Hallands län': 'Q10516328',
    'Västra Götalands läns södra': 'Q10718252',
    'Västra Götalands läns östra': 'Q10718254',
    'Norrbottens län': 'Q10602726',
    'Kalmar län': 'Q10542857',
    'Malmö kommun': 'Q10576154',
    'Göteborgs kommun': 'Q10512885',
    'Skåne läns södra': 'Q10671086',
    'Jönköpings län': 'Q10542122',
    'Östergötlands län': 'Q10727869',
    'Södermanlands län': 'Q10688608',
    'Gävleborgs län': 'Q10512458',
    'Örebro län': 'Q10727482',
    'Jämtlands län': 'Q10541717',
    'Västmanlands län': 'Q10718180',
    'Västernorrlands län': 'Q10717998',
    'Uppsala län': 'Q10710251',
    'Blekinge län': 'Q10431240',
    'Gotlands län': 'Q10507695'})

# Prepare values for import
df.columns = ['start_time', 'end_time', 'represents', 'district', 'qid', 'code']
df.start_time = pd.to_datetime(df.start_time).dt.strftime('+%Y-%m-%dT%H:%M:%SZ')
df.end_time = pd.to_datetime(df.end_time).dt.strftime('+%Y-%m-%dT%H:%M:%SZ')

# Utility function to create one claim per row
def create_position_claim(row):
    qualifiers = []
    
    # Start time
    qualifiers.append(wdi_core.WDTime(row.start_time, prop_nr='P580', is_qualifier=True))
    
    # End time
    qualifiers.append(wdi_core.WDTime(row.end_time, prop_nr='P582', is_qualifier=True))
    
    print(row.is_latest_period)
    if row.is_latest_period:
        # District
        qualifiers.append(wdi_core.WDItemID(row.district, prop_nr='P768', is_qualifier=True))
        
        # Represents
        qualifiers.append(wdi_core.WDItemID(row.represents, prop_nr='P1268', is_qualifier=True))
    
    ref = []
    
    # Riksdagen person_id
    ref.append(wdi_core.WDExternalID(row.code, prop_nr='P1214', is_reference=True))
    
    # Date retrieved
    now = datetime.now().strftime('+%Y-%m-%dT00:00:00Z')
    ref.append(wdi_core.WDTime(now, prop_nr='P813', is_reference=True))
    
    position_claim = wdi_core.WDItemID('Q10655178', prop_nr='P39',
                                       qualifiers=qualifiers,
                                       references=[ref])
    return position_claim

def create_claims_for_mp(df, qid):
    """Collect all claims for a given MP."""
    frame = df[df.qid == qid].copy()
    frame = frame.sort_values('start_time')
    frame = frame.reset_index(drop=True)
    frame['ordinal'] = frame.index
    frame['is_latest_period'] = frame.ordinal == frame.ordinal.max()
    frame['claim'] = frame.apply(create_position_claim, axis=1)
    wd_item = wdi_core.WDItemEngine(wd_item_id=qid, data=list(frame.claim), append_value='P39')
    return wd_item

# login object
login_instance = wdi_login.WDLogin(user=WD_USERNAME, pwd=WD_PASSWORD)

# Write data
for mp in df.qid.unique():
    item = create_claims_for_mp(df, mp)
    item.write(login_instance,
               bot_account=False,
               edit_summary=BOT_SUMMARY)
    time.sleep(5)

P1268 vs P4100

[edit]

I notice that the vast majority of position held (P39) statements for member of the Swedish Riksdag (Q10655178) use a represents (P1268) qualifier to connect to the party/group, when in most other countries we've standardised on parliamentary group (P4100) now. My suspicion is that this is mainly because that's how the data was originally entered, before P4100 was created, and we should run a bulk migration, but perhaps there's a reason to stick with P1268? --Oravrattas (talk) 15:22, 23 June 2020 (UTC)[reply]

If parliamentary group (P4100) is the standard, then I think it makes sense to run a bulk migration. The term "partigrupp" sounds a bit odd in Swedish circumstances though, as it's always a single party you represent. Popperipopp (talk) 08:40, 26 June 2020 (UTC)[reply]
I can't really say anything about the connotations of the Swedish name, or know if there's a more suitable term, but "group" in this sense usually means a group of parliamentarians, rather than a group of parties. Members of more than one party can join together into a multi-party group, but that's not a necessary feature, and even in countries where there's largely a one-to-one mapping it's often helpful to distinguish the "parliamentary party" (that you can only be a member of if you're elected the parliament) from the wider party with public membership. In some countries this distinction is much more formalised in others, but even where there's very little perceived difference there can sometimes be a difference in terms of leadership (the wider party leader may not be a member of a given legislature, e.g. if they're an MEP) and sometimes also in terms of membership (someone can be expelled from, or resign from, the parliamentary party but not the wider political party or vice versa). In terms of Wikidata modelling, I think it's definitely helpful to be as consistent as possible, so that we can reuse queries and tools, and to make it easier for people to do research across multiple countries. Such a migration should also be fairly trivial with the latest version of wikidata-cli, which now supports exactly this. I'm happy to run that migration if people like. --Oravrattas (talk) 17:05, 27 June 2020 (UTC)[reply]
Sounds good to me. It would be great if you could migrate that. Please ping before you start so we know when to switch qualifier when adding new statements. Popperipopp (talk) 23:16, 27 June 2020 (UTC)[reply]
@Popperipopp: Those are starting to migrate now at https://tools.wmflabs.org/editgroups/b/wikibase-cli/9194d5a15ae2b/ — I can easily re-run if any new statements appear using this. --Oravrattas (talk) 05:06, 28 June 2020 (UTC)[reply]
I was looking at the examples of represents (P1268) and parliamentary group (P4100) and got the idea of P1268 fitting better. However, that seems to have been reverted yesterday. I might also change the Swedish label of P4100, because right now it feels misleading to say the least. Ainali (talk) 07:52, 28 June 2020 (UTC)[reply]
Ah, that example on represents (P1268) predated the creation of the property for parliamentary group (P4100), and removing it seems to have been overlooked for quite some time! P1268 certainly used to be one of the approaches that people took for modelling this, but it was only one amongst many, and how it used was quite inconsistent (most of the remaining uses are for member of the Parliamentary Assembly of the Council of Europe (Q27137568) where it's used to signify the country, rather than a party). Standardising on P4100 everywhere has been generally very useful, especially for re-usability of queries and tools, and anyone who needs more nuance can always look at the P31 on the target item (with separate hierarchies for parliamentary group (Q848197) and political party (Q7278) in some countries). --Oravrattas (talk) 09:33, 28 June 2020 (UTC)[reply]
I agree that represents (P1268) is the wrong qualifier to use for members of the Swedish Riksdag, but parliamentary group (P4100) is no more right. All members of the Riksdag represent their party and nothing else since about a hundred years back, so neither of these quailifiers are necessary. Back in the 1800's it is a different matter. /ℇsquilo 07:29, 23 July 2020 (UTC)[reply]
A qualifier is definitely needed since it makes it a lot easier to query for whom they represent. They can either represent their party or (not and) nothing else, i.e. they have left their party. Ainali (talk) 19:33, 23 July 2020 (UTC)[reply]

Challenge with P2715

[edit]

If a person is elected MP, then immediately becomes a minister (Q83307) in the government (or takes a leave of absence on the first day), we currently don't record that the person was in fact elected in (P2715) in a given election. This means queries like these will always be incomplete. Popperipopp (talk) 08:25, 26 June 2020 (UTC)[reply]

That's a very good point. I'm not sure how we should solve it though. (Btw, I ordered the query.) Ainali (talk) 17:10, 26 June 2020 (UTC)[reply]
In case anyone stumbles on this in the future, this has been resolved by creating statements for the MP's in question, and setting the start and end date to the same value. Popperipopp (talk) 15:45, 15 December 2021 (UTC)[reply]

Multiple P1214s?

[edit]

I have noticed that quite a mew people have multiple Riksdagen person-ID (P1214) statements: e.g. Jakob Forssmed has both "0ab695ba-6994-11d7-ae76-0004755038ce" and "0982795248728". Both of those resolve to what appear to be identical HTML versions of the data.riksdagen.se items, though only the latter version gets displayed on that page (as "Intressent_id"). The underlying raw data, however, also includes the former as a "sourceid". The constraint format for P1214 currently also only matches the latter. I don't really understand the difference between the two, but it would be good to standardise on which is being used. It should also be fairly simple to automatically migrate from one to the other — or even add both for everyone (though if we were to decide on the latter, it would be useful to use a qualifier to denote which is which, so they can be queried independently.) --Oravrattas (talk) 15:45, 29 June 2020 (UTC)[reply]

Just a few days ago Swedish Parliament person GUID (P8388) was created, so we should migrate the guid to that one. Ainali (talk) 18:08, 29 June 2020 (UTC)[reply]

Government reshuffle 5 February 2021

[edit]

I think I managed to get it all entered correctly, but great someone (@Ainali:?) can double check. Source (in Swedish). Belteshassar (talk) 10:50, 5 February 2021 (UTC)[reply]

We should make a maintenance query for this. A query that get all current ministers might also be useful on Wikipedia as a list. Ainali (talk) 08:31, 7 February 2021 (UTC)[reply]
Here's a first stab at such a query:
SELECT ?item ?itemLabel ?ministerLabel ?start WHERE {
   ?minister wdt:P31 wd:Q294414 ;
            wdt:P361 wd:Q930729 .
  ?item p:P39 ?m.
  ?m ps:P39 ?minister; pq:P580 ?start .
  OPTIONAL { ?m pq:P582 ?end }
  FILTER(!BOUND(?end)|| ?end > NOW())
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }    
}
ORDER BY ?start
Try it!
-- Ainali (talk) 09:09, 7 February 2021 (UTC)[reply]
I am not sure if the dates from before 2019 is correct. Did they never resign and have a continuous streak or should there be a new period? Besides that, it seems pretty ok. Ainali (talk)
I noticed the confusion about deputy and created the new item Vice Prime Minister of Sweden (Q105359146). Ainali (talk) 14:38, 7 February 2021 (UTC)[reply]

Some stats over time

[edit]

Thanks to the great work of Popperipopp there are now some stats on our coverage over time. See images below which shows how many members of parliament Wikidata had data for on each date in history. Ideally, this should be 349. The headers are when the data in the graph is from (that is, the one in the bottom is the newest):

June 23, 2021

June 23, 2021

July 01, 2021

July 01, 2021

July 04, 2021

July 04, 2021

July 08, 2021

July 08, 2021

The spikes are caused by that the start and end date are the same in the official data from the Riksdag on the day when the mandate shifts. Ainali (talk) 19:22, 11 July 2021 (UTC)[reply]

December 15, 2021

The whole dataset from 1971 to present time is now in pretty decent shape. Popperipopp (talk) 15:29, 15 December 2021 (UTC)[reply]

December 15, 2021

This is very impressive work! Belteshassar (talk) 22:10, 15 December 2021 (UTC)[reply]

Combined ministerial positions

[edit]

I was comparing the information on the new Cabinet against the list at https://www.government.se/government-of-sweden/, and I'm a little bit confused about people like Morgan Johansson (Q5887217). In Wikidata he currently holds the two distinct positions of Minister for Justice (Q3315958) and Minister for Migration (Q18183298), but the official site seems to class this as currently being a single position of "Minister for Justice and Migration". Is this really two separate positions, or is this entered in Wikidata like this mainly because it's easier to keep the two parts separate than to create a new combined successor post to the two prior distinct ones (and then quite likely need to split it up again later), and this gains more consistency over time, etc? --Oravrattas (talk) 06:11, 19 July 2021 (UTC)[reply]

The latter. But it's a tricky area and I'm happy to discuss alternative solutions. In contrast to information from Riksdagen, the government does not provide structured data on positions, afaik. Popperipopp (talk) 08:54, 19 July 2021 (UTC)[reply]
@Popperipopp: yeah, it's hard to know what to do with those. For a few other countries I've gone through the dance of creating new items each time the portfolio changes substantially, but it's definitely a lot more work that way. At the minute we don't really model what a ministerial position really has responsibility for, other than through quite coarse-grained claims like subclass of (P279): justice minister (Q17763739). Maybe once we evolve a better way of saying what their portfolio actually included at different times it'll become more apparent when we would benefit from separate items vs lots of start and end dates on things that were combined and then separated again etc. --Oravrattas (talk) 10:28, 19 July 2021 (UTC)[reply]