Pop Quiz (no cheating)
O'Leary or IDiot generator, edited for brevity.
| ||||
Exactly so! While I was writing/debugging I made many searches of the strings that the shaney was coming out with back into UD because I was sure that they were written like that originally and the program was somehow not working and just spitting out the input. But no, every single time the sentence was not there.
I've actually got very little idea of how the shaney is generated in the first place, I've just pasted in a chunk of source code I eventually found. I know it's based on Markov chanins but I can barely understand my own code after a week never mind this:
for word in words:
if prev1 != '' and prev2 != '':
key = (prev2, prev1)
if dict.has_key(key):
dict[key].append(word)
else:
dict[key] = [word]
if prev1[-1:] == '.':
end_sentence.append(key)
I know what all the bits do individually but has a whole, not figured much out just yet. But the nice thing about programming is you don't have to reinvent the wheel. Somebody else probably already wrote what it is that you are trying to do and it's out there to include in your work. I knew of the shaney, I just had to hope the source was out there and it was. I'll reproduce it in full shortly.
No comments:
Post a Comment