This is the README for the Swedish Poligraph, by Stian Rødven Eide, Språkbanken Text, University of Gothenburg In this file we have included the main Prolog file, which lists (a) the available predicates (b) the loaded modules (c) rules with comments The canonical URL for this project is https://spraakbanken.gu.se/poligraph We ask that any work using this data cites (Rødven Eide, 2019), details of which can be found on the above URL. :- module(poligraph, [rid_sname/2, rid_wname/2, rid_lname/2, rid_fname/2, rid_name/2, rid_wid/2, rid_party/2, position/8, anforande/3, dokid_date/2, meet_anf_topic/3, had_previous_anf/8, had_anf/6, had_anf/4, was_in_rd/3, was_mp/3, was_minister/3, was_ledig/3, has_position/3, has_position_period/5, has_position_lname/6, has_position_fname/6 ]). :- [rid_wid]. :- [fname]. :- [lname]. :- [sname]. :- [wname]. :- [position]. :- [party]. :- [anf_ids]. :- [meetdates]. :- [meet_anf_topic]. /* Some potentially confusing terms: rid = Riksdagen-ID = MP-ID (A unique ID for each elected MP) dok_id = Meeting-ID (A number referencing a particular meeting in the parliament) anf = anförande = speech (An entry in a parliamentary debate) */ /* Predicates defined in other source files: rid_wid/2 (Maps an MP-ID to that person's Wikipedia-ID) fname/2 (Maps an MP-ID to that person's first name) lname/2 (Maps an MP-ID to that person's last name) sname/2 (Maps an MP-ID to that person's sorting name, e.g. 'Löfven,Stefan') wname/2 (Maps an MP-ID to that person's Wikipedia name, e.g. 'Stefan Löfven') position/8 (Each entry describes one position that an MP has or has had in the Swedish parliament. This can be being elected to the parliament itself, as a minister or as a member of a commission. The arguments are: 1. MP-ID (Unique ID for each MP) 2. Agency-code (e.g. 'kam' designates the Parliament) 3. Role (The person's role in the agency, e.g. 'ledamot', 'suppleant') 4. From (Starting date of the position) 5. To (End date of the position) 6. Type (Type of position, e.g. 'kammaruppdrag' for the parliament) 7. Uppdrag (Name of angency, where applicable, the info here varies) 8. Status (The person's status in the given agency in the given timespan)) rid_party/2 (Maps an MP-ID to that person's party affiliation) anforande/3 (Maps a speech (anförande) to a meeting number (dok_id) and an MP-ID) dokid_date/2 (Maps a meeting number (dok_id) to its date) meet_anf_topic/3 (Maps a topic to a meeting number (dok_id) and a speech number) */ /* For any name resolution, we match, in order: Sort-name, e.g. 'Löfven,Stefan' Wiki-name, e.g. 'Stefan Löfven' Last-name, e.g. 'Löfven' First-name, e.g. 'Stefan' */ rid_name(Rid, Name) :- rid_sname(Rid, Name). rid_name(Rid, Name) :- rid_wname(Rid, Name). rid_name(Rid, Name) :- rid_lname(Rid, Name). rid_name(Rid, Name) :- rid_fname(Rid, Name). /* Given a speech, designated by MeetNr and SrcAnfNr, this gives all previous speeches on the same topic in the same meeting that took place before the source speech */ had_previous_anf(TargetName, TargetRid, TargetAnfNr, TargetParty, Topic, MeetNr, SrcAnfNr, Date) :- had_anf(TargetName, TargetRid, TargetAnfNr, TargetParty, Topic, MeetNr), meet_anf_topic(MeetNr, SrcAnfNr, Topic), dokid_date(MeetNr, Date), SrcAnfNr > TargetAnfNr. /* As above, this gives all previous speeches on the same topic, but in a previous meeting */ had_previous_anf(TargetName, TargetRid, TargetAnfNr, TargetParty, Topic, TargetMeetNr, SrcAnfNr, TargetDate) :- had_anf(TargetName, TargetRid, TargetAnfNr, TargetParty, Topic, TargetMeetNr), meet_anf_topic(SrcMeetNr, SrcAnfNr, Topic), dokid_date(TargetMeetNr, TargetDate), dokid_date(SrcMeetNr, SrcDate), TargetDate < SrcDate. /* This gives all speeches on a topic, with speaker, speech number, party and meeting number */ had_anf(Name, Rid, Anf, Party, Topic, MeetNr) :- rid_name(Rid, Name), rid_party(Rid, Party), anforande(MeetNr, Anf, Rid), meet_anf_topic(MeetNr, Anf, Topic). /* This gives the name, ID and party affiliation for all speeches on a given date */ had_anf(Name, Party, Rid, Date) :- rid_name(Rid, Name), anforande(Dokid, _, Rid), dokid_date(Dokid, Date), rid_party(Rid, Party). was_in_rd_on_date(Name, Date) :- rid_sname(_, Name), was_in_rd(Name, From, Tom), Date >= From, Date =< Tom. /* Who was in the parliament in a given period */ was_in_rd(Name, From, Tom) :- was_mp(Name, From, Tom). was_in_rd(Name, From, Tom) :- was_minister(Name, From, Tom). /* Who was an elected MP (non-minister) in a given period */ was_mp(Name, From, Tom) :- rid_name(Rid, Name), position(Rid,'kam',_,From,Tom,_,_,Status), Status \= 'Ledig'. /* Who was a minister in a given period */ was_minister(Name, From, Tom) :- rid_name(Rid, Name), position(Rid,_,Minister,From,Tom,_,_,Status), Status \= 'Ledig', sub_atom(Minister,_,_,0,'minister'). /* Who was on leave from the parliament in a given period */ was_ledig(Name, From, Tom) :- rid_sname(Rid, Name), position(Rid,'kam',_,From,Tom,_,_,Status), Status = 'Ledig'. /* A simplification of position/8: Matches MP's by name to their assignments */ has_position(Name, Position, Where) :- rid_name(Rid, Name), position(Rid,_,Position,_,_,_,Where,_). /* Gets the period in which an MP had a given position */ has_position_period(Name, Position, Where, From, To) :- rid_name(Rid, Name), position(Rid,_,Position,From,To,_,Where,_). /* Retrieves positions based on last name only */ has_position_lname(Lname, Name, Position, Where, From, To) :- Name = Sname, rid_sname(Rid, Sname), rid_lname(Rid, Lname), position(Rid,_,Position,From,To,_,Where,_). /* Retrieves positions based on first name only */ has_position_fname(Fname, Name, Position, Where, From, To) :- Name = Sname, rid_sname(Rid, Sname), rid_fname(Rid, Fname), position(Rid,_,Position,From,To,_,Where,_).