2
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import random
|
|
4 import sys
|
|
5 import urllib2
|
|
6
|
|
7 from optparse import OptionParser
|
|
8 from pprint import pprint
|
|
9 from wordstream.api import Corpus
|
|
10
|
|
11 def dissociate(args=sys.argv[1:]):
|
|
12 parser = OptionParser()
|
|
13 options, args = parser.parse_args()
|
|
14
|
|
15 corpus = Corpus()
|
|
16 corpus.feed_stuff(*args)
|
|
17 corpus.scramble()
|
|
18
|
|
19 while corpus:
|
|
20 word = random.choice(corpus.keys())
|
|
21 inedible = True
|
|
22 while corpus.get(word):
|
|
23 inedible = False
|
|
24 print word + ' ',
|
|
25 word = corpus.eat(word)
|
|
26 if inedible: # eat it anyway
|
|
27 corpus.eat(word)
|
|
28
|
|
29 if __name__ == '__main__':
|
|
30 dissociate()
|