NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

sejmRP: An Information About Deputies and Votings in Polish Diet from Seventh to Eighth Term of Office

Piotr Smuda, Przemysław BiecekOpenalex Unknown 2015 · OpenAlex

Abstract

The sejmRP R package provides a set of functions that access information about deputies and votings in the Polish Diet (Sejm) from the official webpage. The package was developed as a result of an internship in the MI2 Group at the Faculty of Mathematics and Information Science, Warsaw University of Technology. It facilitates the programmatic collection and structuring of parliamentary data for the 7th and 8th terms of office.

Introduction

While parliamentary transparency is a cornerstone of democracy, "public" data is not always "accessible" data. The official website of the Polish Sejm contains a wealth of information, but this data is often trapped in complex HTML structures that are difficult to query at scale. For political scientists, sociologists, or data journalists, manually tracking how 460 deputies voted across thousands of sessions is a Herculean task.

The sejmRP R package addresses this bottleneck by providing a specialized toolkit for scraping, structuring, and analyzing data from the Polish Diet. By automating the collection of deputy profiles, voting records, and speech transcripts into a PostgreSQL database, it transforms a complex government website into a researcher-ready relational dataset.

Methodology and Database Integration

The package is built on a stack of standard R tools for web scraping, such as rvest and xml2, but adds a layer of domain-specific logic tailored to the Sejm's web architecture. Notably, the authors implemented "safe" versions of scraping functions that include built-in retries and sleep intervals to ensure resilience against network instability or server-side rate limiting.

Unlike many scrapers that simply return in-memory data frames, sejmRP is designed to build and maintain a local PostgreSQL database. It includes functions to initialize the schema and incrementally update tables as new data becomes available. For instance, the deputies_add_new function allows users to append new deputy records to the existing database structure while maintaining specific metadata like the term of office.

Parameters for the deputies_add_new function, illustrating the database-centric approach to data ingestion.

Data Retrieval and Analysis

The package serves as a pipeline for live data, targeting four core entities: Deputies, Votings, individual Votes, and Statements (full transcripts of parliamentary speeches). A key technical challenge addressed is ensuring referential integrity; the package includes matching logic to ensure that a deputy mentioned in a voting record is correctly linked to their profile and speech transcripts.

To facilitate research, sejmRP provides high-level functions for data retrieval. These allow users to query the database using R syntax to find specific text patterns in speeches or filter votes by club, date, or topic. The deputies_get_data function, for example, provides a streamlined way to pull structured information from the database for further statistical analysis.

Parameters for retrieving deputy data via the sejmRP API, allowing for filtered queries based on the term of office.

Key Insights and Results

By treating the Sejm as a relational system rather than a collection of documents, sejmRP enables complex queries, such as correlating speech frequency on specific topics with voting behavior. The package also handles local nuances, such as Polish diacritics and Windows-specific encoding issues, ensuring data integrity across different operating systems.

The package successfully automates the creation of massive datasets. According to documentation examples, the votes table can exceed 2.8 million rows, while the statements table can house over 43,000 transcripts. This unified API replaces hundreds of lines of custom scraping code with simple, reproducible function calls.

Limitations and Future Work

The current version of sejmRP is focused on the 7th and 8th terms (roughly 2011–2019). As the Polish parliament moves into newer terms, the package requires updates to accommodate potential changes in the website's HTML structure. Additionally, the reliance on PostgreSQL adds a setup hurdle for users only familiar with flat files. Future directions could include adding visualization wrappers for voting blocs or extending the scraper to include committee-level data.

Summary updated

BibTeX
@inproceedings{smuda2015sejmrp,
  author = {Piotr Smuda and Przemysław Biecek},
  title = {{sejmRP: An Information About Deputies and Votings in Polish Diet from Seventh to Eighth Term of Office}},
  booktitle = {Openalex Unknown},
  year = {2015},
  doi = {10.32614/cran.package.sejmrp},
}
Figure