Continuing on last month's theme on Swedish parliamentary data, we would like to introduce a new tool designed to use and explore them.
The Swedish PoliGraph is unfortunately not able to tell when a politician lies, at least not yet. Rather it is a graph that connects politicians to their roles and participation in the Swedish parliament. With it, we can ask questions such as:
- Who was present in the parliament on a given date?
- Who spoke on that date?
- Which party speaks more on which topics?
- Which politician has participated in which commissions?
The development of the Swedish PoliGraph was initiated in order to assist with Named Entity Resolution, the process of automatically deciding to whom a name in a text refers, but we hope that it can be useful for many other tasks as well.
While the contents of the graph is basically limited to that from riksdagens öppna data, links from each politician to their respective Wiki-ID have been implemented, making it possible to extend the graph with biographical information from Wikipedia, such as date and place of birth or other prominent positions in government or industry.
How to use it
The Swedish PoliGraph is implemented in Prolog, a logical programming language that is particularly suited for giving answers to queries. A typical Prolog program consists of facts and rules, expressed as logical predicates. A few examples of available facts are:
Here, the first fact says that the MP with MP-ID 0218878014918 has the family name Löfven, the second that this MP is affiliated with the party Socialdemokraterna and the third that this person was prime minister from 2014-10-03 to 2018-12-31.
A rule typically looks like this:
had_anf(Name, Party, Rid, Date) :-
anforande(Dokid, _, Rid),
Here, the symbol
:- can be understood as "if and only if". A rule states that the predicate on the first row is true if and only if the predicates on the following rows are true. In this case, the rule says that a politician spoke in the parliament on a given date if (and only if) there exists a speech by that politician and that speech was held on that date. By also including name and party in the rule, we can also either retrieve that data or use it as a filter. This is because in Prolog, any argument can be used as either a match or a variable. Any unquoted string starting with an upper-case letter will be treated as a variable. Thus:
will respond "True" if Stefan Löfven spoke in the parliament on 2015-03-20, and "False" if not, whereas:
had_anf(Name, Party, Rid, 20150320).
will return all combinations of name, party and MP-ID for which the statement is true, that is, all politicians that spoke in the parliament on 2015-03-20.
With the use of Pengines, a Prolog module that allows for remote queries, we have also published a web demo of the Swedish PoliGraph. For obvious reasons, replicating the flexibility of Prolog on a web page is not feasible, so we have chosen two predifined functions that demonstrate some of the functionality: One that, given a date, lists all MPs who were in parliament that day, and another that allows you to search for names and see what positions in the parliament whoever with those names had.
If you are curious to explore this further, the paper referenced from the demo page offers more details and explanations.