Mining the Bundestag

Code: Here

Did you know that the german parliament publishes protocols of all of its proceedings in PDF format? It is relatively straight-forward to download and parse them, so we can easily collect a dataset of transcripts of what seems to be every speech in the Bundestag since the second world war.

My original idea was to mine the speeches for word associations: some words will be associated with other words, based on the intended connotation, and this association might change over time as the connotations change. Also, these associations can probably be correlated to individual parties. Furthermore, this dataset could be used to automatically identify emerging topics.

Protocols

Scraping

Scraping the PDF documents is not difficult, however, extracting the text from the PDFs is can be a bit tedious. In the end, I had to use an OCR solution based on Tesseract that reads the text from some hand-selected locations in the documents. The results are far from perfect, and some additional pre-processing is required.

Language Model

Now that we have a dataset of transcripts from the bundestag, creating a GPT-2-based language model that generates speeches is not difficult. Below is an example output:

Präsident Dr. Wolfgang Schäuble:

Letzter Redner in dieser Debatte ist der Kollege Michael Brand für die CDU/CSU-Fraktion.

(Beifall bei der CDU/CSU)

Michael Brand (CDU/CSU):

Vielen Dank, Herr Präsident, - Sehr geehrte Damen und Herren Abgeordnete! Die Zustände in den Flüchtlingslagern der Vereinten Nationen sind unerträglich.

Wir müssen jetzt schnell Lösungen finden.

Die Vereinten Nationen, das ist die UN-Vollversammlung, haben die Krise des UN-Flüchtlingsprogramms 2015 beschlossen. Die Krise hat zu massiven Versorgungsengpässen geführt, und das bei so viel Leid und Elend in den Lagern, Die Situation der vielen Flüchtlinge, die vor Krieg, Konflikten und vor allem vor den Toren der Hauptstadt Schutz und Hilfe suchen, ist katastrophal. Der UNHCR, der weltweit die Vergabe von humanitärer Hilfe, auch durch die Vereinten Nationen, durchführt, ist einer der großen Arbeitgeber in diesem Bereich. Es ist ein großer Erfolg, dass der UN-Plan 2015 heute veröffentlicht wurde. Das zeigt: Das UN-Flüchtlingsprogramm ist ein Erfolg - und das wird auch so bleiben. Die Lage der Flüchtlinge in Deutschland hat sich im Vergleich zu den Jahren davor nicht weiter entspannt, im Gegenteil: Die UN-Lager in Deutschland sind überbelegt und überlastet. Das ist ein Problem, dem wir uns auch im nächsten Jahr stellen müssen.

Die Situation in den Flüchtlingslagern ist weiterhin sehr belastet. Es gibt immer noch viele Binnenflüchtlinge. Es gibt immer noch viele Flüchtlinge, die versuchen, in Nachbarländer zu kommen. Die Lage der Flüchtlinge im Libanon ist extrem. Die Lage in Afghanistan ist ebenfalls extrem, Die Situation in Pakistan und in Afghanistan ist ebenfalls extrem, und es gibt weiterhin Flüchtlinge, die aus den Flüchtlingslagern nach Indien oder aus Nordafghanistan in den Norden oder in den Irak kommen.

Im Jahr 2018 - das wurde schon erwähnt - wird es eine große Zahl an Asylbewerbern geben, die zu uns gekommen sind, und wir werden in diesem Jahr insgesamt über 1 Million Flüchtlinge und Einwanderer haben, Diese Menschen brauchen eine sichere, legale, aber faire und Unterstützung, Die Vereinten Nationen müssen jetzt die richtigen Signale aussenden und die richtigen Signale aussenden.

Wir können es uns nicht leisten, diese Menschen alleine zu lassen, Deshalb haben wir heute das Recht, darüber zu entscheiden, ob die Situation weiterhin für die Menschlichkeit haft oder für die Rechtsstaatlichkeit in den Flüchtlingslagern sprechen.

Wir sollten nicht in Abwägung kommen, ob diese Menschen, die wir haben, weiterhin Schutz und humanitäre Hilfe brauchen, und wir müssen ihnen auch weiterhin eine Heimat bieten, in denen sie leben können und in denen die Regeln, die Gesetze und die Regeln der Gesellschaft gelten, Wir dürfen nicht zulassen, dass diese Menschen in den Lagern, von denen wir in den vergangenen Jahren gesprochen haben, wieder in ihre Heimat zurückkehren. Das ist unser gemeinsamer Anspruch, auch im Interesse der Vereinten Nationen.

Video Recordings

The Bundestag has also been publishing video recordings of all speeches for a couple of years now, so there are huge volumes of high resolution video and audio data (as well as transcriptions?), recorded in a standardized environment, of every major german politician publicly available on the internet. What could possibly go wrong.

Using the videos is allowed for educational purposes. The following might give you an idea (educate you) about what might be possible with this data: using pre-trained face detectors and Tesseract, we can extract faces, names and party membership information from the videos.

Random sample of crops from the video recordings.

Random sample of crops from the video recordings.

Autoencoders

An Autoencoder (AE) is a simple neural network architecture that can be used for dimensionality reduction. It takes an input image $x$ which is then sent through an encoder $E(x)$ that compresses the input into a lower dimensional latent representation $z$. This $z$ is then processed by a decoder $D(z)$ which decompresses $z$ back into $\hat{x}$. During training, we optimize the encoder and decoder jointly to minimize (in this case) the sum of the squared errors between $x$ and $\hat{x}$. This way, the AE learns to efficiently reduce the dimensionality of the input, while ensuring that the original input can be reconstructed.

Architecture of an Autoencoder

Architecture of an Autoencoder

AEs can be used for clustering, since similar inputs tend to be close to each other in the latent space.

T-SNE of latent space generated by Deep Convolutional Autoencoder.

T-SNE of latent space generated by Deep Convolutional Autoencoder.

We can also use AEs to interpolate between different inputs. Given two images $x_1$ and $x_n$, we can calculate the point in the latent space for each of them by passing them through the encoder. We can then interpolate between both points in the latent space and send each of the resulting latent representations $z_1, …, z_n$ through the decoder to produce a video $\hat{x}_1, …, \hat{x}_n$ that shows a smooth transition between the original images. Below is a video that interpolates between images of three different politicians.

Interpolating between points in the latent space.

Interpolating between points in the latent space.

There are different variations of AEs, many of which impose additional constraints on the latent space to induce a specific structure, such as variational AEs. Interestingly, in this case, the vanilla AE seems to be sufficient to learn a “smooth” latent that can be used for interpolation.

I will update this page if there are new results.


Last Updated: 22 Jan. 2023
Categories: Data Mining
Tags: Bundestag