Git Product home page Git Product logo

zweischlagzeilen's Introduction

zweischlagzeilen Project -- ZwoSchlagzeilen Twitter-Bot

@ZwoSchlagzeilen ist ein Twitter-Bot, der Schlagzeilen großer deutscher Nachrichtenportale verquirlt und stündlich postet. Er generiert im besten Fall so etwas wie "Fast Richtige Schlagzeilen" (Titanic). Im Grunde genommen ist es die deutsche Variante für das amerikanische Vorbild @TwoHeadlines.

--

@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.

How does it work?

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 one headline as "seed headline". An trigram language model is built from all but the seed headline. The seed headline is cut at a random point so that only up to the first half of it is used as seed input for generating a random sequence of words from the trigram model. This sequence of words is the randomly generated headline that is posted to the Twitter account using tweepy.

Requirements

The script has been tested with Python 3.8 to 3.10.

The following Python packages need to be installed -- all are available via PyPI:

"conf.py" is not in the repository. You will need to create a file "conf.py" with the following content:

TWITTER_CONSUMER_KEY = '...'
TWITTER_CONSUMER_SECRET = '...'
TWITTER_ACCESS_KEY = '...'
TWITTER_ACCESS_SECRET = '...'

# cut out the following substrings from headlines:
CUT_SUBSTRINGS = (
    u'*** BREAKING NEWS ***',
)

# location where to store previously fetched headlines
HEADLINES_COLLECTION = os.path.join('data', 'headlines.json')

# timeout in seconds when fetching a newsfeed
FEED_FETCH_TIMEOUT = 15

# how long to keep headlines
KEEP_DAYS = 28

# which ngram model to use
NGRAMS_N = 3

zweischlagzeilen's People

Contributors

internaut avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.