Edit:
The accompanying code had a few bugs that were otherwise unrelated to the question as titled. The answer is simple enough, so I'm eliminating the irrelevant code so that the question, as asked in the title, and answer are more clearly intelligible to those searching for such things. Thanks to everyone who took the time to read the code and give me some feedback!
Original question, abridged:
I seem to be having trouble when my Python script tries to access the dict entry '"__main__":'
, which is keyed by '__name__ =='
. Is my problem related to use of these strings as variables, or is it more likely that my script is failing elsewhere? (SPOILER:
My algorithm was wrong.)
KeyboardInterrupt
- what exactly is the problem?\__name__ == "\__main__"
Investigating now.random.sample
(ngram_to_kwords
andgibbs_sample_data
), the possibility exists of choosing an item that failed previously, allowing it to loop continuously without success. You need to somehow remove the failed attempts from the pool of choices until the loop is finished.