tommeagher / heroku_ebooks

An archive of a script to generate Markov chains and to post to an _ebooks account on Twitter using Heroku. No longer actively supported.
264 stars 163 forks source link

When setting ORDER = 1 bot fails #10

Closed sroerick closed 8 years ago

sroerick commented 8 years ago

The bot works fine when I run with ORDER = 2/3.

But when I run ORDER = 1 I get the following :

Traceback (most recent call last): File "ebooks.py", line 94, in ebook_tweet = mine.generate_sentence() File "/app/markov.py", line 54, in generate_sentence restup = (res[-2], res[-1]) IndexError: list index out of range

tommeagher commented 8 years ago

Thanks for filing this issue, Roerick. Much appreciated. It's been a while since I've looked at this code, but I'll dig into it and see what I can do to fix it.

sroerick commented 8 years ago

Thanks Tom!

I'm pawing through this as well. I've never played with bots before and I had a lot of fun setting this up. :D

But don't expect much I don't know what i'm doing. :100:

cyphunk commented 8 years ago

This code controdicts itself if ORDER is 1:

        if len(res)==self.order:
                restup = (res[-2], res[-1])

res[] will contain a selection from self.beginnings which may look something like the following when ORDER is 2: [['Hope', 'for'], ["That's", 'our'], ['Next', 'stop']], or when ORDER is 1: ['Hope'], ["That's"], ['Last']]. Setting the code to ignore and accept res of len 1, so that ORDER 1 doesn't cause code to crash... just results in two word lengthed sentences.