User:Inge Hoonte/command line type writer: Difference between revisions
Inge Hoonte (talk | contribs) (Created page with "File:Inge_avatar.png File:EvoCam Movie 3") |
Inge Hoonte (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
[[File:Inge_avatar.png]] | [[File:Inge_avatar.png]] | ||
[[ | |||
# goofy sentence generator | |||
import random | |||
def make_sentence(part1, part2, part3, part4, part5, n=1): | |||
"""return n random sentences""" | |||
# convert to lists | |||
p1 = part1.split('\n') | |||
p2 = part2.split('\n') | |||
p3 = part3.split('\n') | |||
p4 = part4.split('\n') | |||
p5 = part5.split('\n') | |||
# shuffle the lists | |||
random.shuffle(p1) | |||
random.shuffle(p2) | |||
random.shuffle(p3) | |||
random.shuffle(p4) | |||
random.shuffle(p5) | |||
# concatinate the sentences | |||
sentence = [] | |||
for k in range(n): | |||
try: | |||
s = p1[k] + ', take the avatar ' + p2[k] + ' and execute ' + p3[k] + ' make a move ' + p4[k] + ' and say ' + p5[k] | |||
s = s.capitalize() + '.' | |||
sentence.append(s) | |||
except IndexError: | |||
break | |||
return sentence | |||
# break a typical sentence into 5 parts | |||
# p1: who in the audienc | |||
part1 = """\ | |||
Birgit | |||
Inge | |||
The neighbor""" | |||
# p2: which avatar | |||
part2 = """\ | |||
tail | |||
helen | |||
cat""" | |||
# p3: make action | |||
part3 = """\ | |||
/a1 | |||
/a2 | |||
/a3""" | |||
# p4: move avatar where? | |||
part4 = """\ | |||
up the screen | |||
bottom | |||
left | |||
anywhere""" | |||
# p5: say this text: | |||
part5 = """\ | |||
hallo | |||
poop | |||
goodbye | |||
the world is great""" | |||
print '-'*60 | |||
sentence = make_sentence(part1, part2, part3, part4, part5, 1) | |||
for item in sentence: | |||
print item | |||
print '-'*60 | |||
""" | |||
""" |
Revision as of 13:43, 7 September 2011
# goofy sentence generator import random def make_sentence(part1, part2, part3, part4, part5, n=1): """return n random sentences""" # convert to lists p1 = part1.split('\n') p2 = part2.split('\n') p3 = part3.split('\n') p4 = part4.split('\n') p5 = part5.split('\n') # shuffle the lists random.shuffle(p1) random.shuffle(p2) random.shuffle(p3) random.shuffle(p4) random.shuffle(p5) # concatinate the sentences sentence = [] for k in range(n): try: s = p1[k] + ', take the avatar ' + p2[k] + ' and execute ' + p3[k] + ' make a move ' + p4[k] + ' and say ' + p5[k] s = s.capitalize() + '.' sentence.append(s) except IndexError: break return sentence # break a typical sentence into 5 parts # p1: who in the audienc part1 = """\ Birgit Inge The neighbor""" # p2: which avatar part2 = """\ tail helen cat""" # p3: make action part3 = """\ /a1 /a2 /a3""" # p4: move avatar where? part4 = """\ up the screen bottom left anywhere""" # p5: say this text: part5 = """\ hallo poop goodbye the world is great""" print '-'*60 sentence = make_sentence(part1, part2, part3, part4, part5, 1) for item in sentence: print item print '-'*60 """ """