Spent all day on a Markov lyric generator tutorial

This is the tutorial which is very good imo but I am still new to python so I had to google every second line. I will now paste the code with my comments about pretty much every line detailing what I understand that wasn’t really detailed in the tutorial. It wont be runable but could be a usefule resource for someone or at least I prove my knowledge here: https://yuseftechnologies.wordpress.com/2015/07/07/markov-the-messy-commented-code-for-reference/

Other issues I ran into were trying to paste a part of the code into the python shell and getting an error similar to this but in the end after restarting the shell I no longer had that issue. https://mail.python.org/pipermail/idle-dev/2005-June/002356.html this link is to a guy who went into more detail and had a solution which is to turn off the subprocess, but the location he gives of where it should be, the line it should be on, must have been for a different version and I’m glad I didn’t try to find it on my own.

Well it’s nearing the end of the night. I had some success in the end. I can use an order of 1 or 2 consistently but using 4 I get errors often and 5 and above I seem to get errors every time. The error is something about „in getNextCharacter
for letter in model[fragment].keys():
KeyError: ‚hing'“

and the „hing“ at the end could be thing, ething, mething, something, to something, etc depending on how large or small my order is but it seems to have to do with the largest word in the string „somthing“.

Also I wasn’t able to call the script from the desktop or shell or anything, I keep getting an error about the argv going out of scope which I know is because I don’t know how to pass any variables to them so I changed the sys.argv1 and sys.argv2 to just me typing in the numbers.

so semi success!

 Traceback (most recent call last):
>    File "C:\PYTHON24\lib\idlelib\rpc.py", line 233, in asyncqueue
>      self.putmessage((seq, request))
>    File "C:\PYTHON24\lib\idlelib\rpc.py", line 333, in putmessage
>      raise IOError
> IOError 
There was a socket error, or the socket no longer exists.  In other
words, the link to the subprocess failed while the IDLE GUI was trying
to pass the compiled code to the subprocess for execution.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:


Du kommentierst mit Deinem WordPress.com-Konto. Abmelden /  Ändern )

Google Foto

Du kommentierst mit Deinem Google-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s