Created
August 3, 2009 09:28
-
-
Save riffm/160445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from random import random | |
letters_map={ | |
0:u'а', | |
1:u'б', | |
2:u'в', | |
3:u'г', | |
4:u'д', | |
5:u'е', | |
6:u'ё', | |
7:u'ж', | |
8:u'з', | |
9:u'и', | |
} | |
def word(): | |
pattern = str(random())[2:] | |
word_ = [] | |
for digit in pattern: | |
try: | |
word_.append(letters_map[int(digit)]) | |
except (ValueError, KeyError): | |
pass | |
return ''.join(word_) | |
def generate_words(count): | |
"""docstring for generate_words""" | |
for i in xrange(count): | |
yield word() | |
def generate_sentences(count): | |
return " ".join(generate_words(count)) | |
if __name__ == '__main__': | |
print generate_sentences(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment