RSS feed to Markov chain

Yesterday I made this script, the results are quite fun.
You can change the URL to whatever feed you like.
First pip install feedparser html2text markovify and then simply run with python3.

import feedparser
from html2text import html2text
import markovify
feed=feedparser.parse('https://haikuinsider.wordpress.com/feed/')
text = ''
for entry in reversed(feed['entries']):
    text+='# '+entry['title']+'\n\n'
    text+=html2text(entry['content'][0]['value'])+'\n'
text_model = markovify.Text(text)

for i in range(20):
    print(text_model.make_sentence())

Nice coolcoder613!

A summary for those who don’t know what the script does: It makes a basic autocomplete from the text gathered in the RSS feed given to it (the autocomplete is based off of Markov chains; if you want the details of how it works, see the section “Text and Markov Chains” in How Markovify works). It then uses the autocomplete to generate 20 sentences!

One fun thing you can try it on is the text you’ve posted in the forum. Here’s a modified script that can do it. Make sure to replace <YOUR USERNAME> with your username :wink:

import feedparser
from html2text import html2text
import markovify
feed=feedparser.parse('https://discuss.haiku-os.org/u/<YOUR USERNAME>/activity.rss')
text = ''
for entry in reversed(feed['entries']):
    text+='# '+entry['title']+'\n\n'
    text+=html2text(entry['summary'])+'\n'
text_model = markovify.Text(text)

for i in range(20):
    print(text_model.make_sentence())

Some highlights of its output for my user:

I can find the commit that fixes it, or else revert the commit that fixes it, or else revert the commit that fixes it, or else revert the commit that fixes it, or else revert the commit causing it.

That might work, I guess…

It loaded the symbols in the bitmap.

Ooh, bitmaps support debug symbols now? When will Debugger support setting breakpoints in PNG images? :laughing:

But it seems WebKitLegacy still works so it could use some more work.

Hmm, is this predicting the future? An update to WebKit’s codebase will break our WebKit2 but our WebKitLegacy will survive?

2 Likes

Fixed the title for you. Simple typo.

1 Like