comparison wordstream/dissociate.py @ 2:df84e61ae1e4

add dissociation
author k0s <k0scist@gmail.com>
date Fri, 12 Feb 2010 00:38:25 -0500
parents
children e21f53582267
comparison
equal deleted inserted replaced
1:af19f44024d3 2:df84e61ae1e4
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()