ZwoSchlagzeilen Twitter-Bot

Oct 2015 • python, twitter, language processing

@ZwoSchlagzeilen is a Twitter-Bot that mixes recent headlines of leading German newspapers and posts one of them each hour. Sometimes it produces funny results. It is basically the German variant for the American archetype @TwoHeadlines.

The script works quite simple. Basically, it uses feedparser to fetch the headlines of several RSS newsfeeds of German newspaper websites. Then, it randomly selects two headlines and mixes them. The mixing is done by identifying the nouns via Part-of-Speech (POS) tagging and then substituting those nouns from one headline by the other headline. For accurate results in the POS tagging process, I use a trained tagger for German language text like explained in this blog post. If we are below the Twitter character limit, we have our final headline, otherwise the whole process starts all over. Finally, the random headline is posted to the twitter account using tweepy.

The source code is a Python 2 script named “zweischlagzeilen” and can be examined in the github repository.

Back