Mercurial > hg > wordstream
diff wordstream/dissociate.py @ 2:df84e61ae1e4
add dissociation
author | k0s <k0scist@gmail.com> |
---|---|
date | Fri, 12 Feb 2010 00:38:25 -0500 |
parents | |
children | e21f53582267 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wordstream/dissociate.py Fri Feb 12 00:38:25 2010 -0500 @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import random +import sys +import urllib2 + +from optparse import OptionParser +from pprint import pprint +from wordstream.api import Corpus + +def dissociate(args=sys.argv[1:]): + parser = OptionParser() + options, args = parser.parse_args() + + corpus = Corpus() + corpus.feed_stuff(*args) + corpus.scramble() + + while corpus: + word = random.choice(corpus.keys()) + inedible = True + while corpus.get(word): + inedible = False + print word + ' ', + word = corpus.eat(word) + if inedible: # eat it anyway + corpus.eat(word) + +if __name__ == '__main__': + dissociate()