|
|
@ -1,3 +1,4 @@ |
|
|
|
import random |
|
|
|
def poetry(): |
|
|
|
filename = '2013_Wages_for_Facebook_[EN].txt' |
|
|
|
path = './manifestos/'+filename |
|
|
@ -6,7 +7,22 @@ def poetry(): |
|
|
|
manifesto = manifesto.replace('\n', ' ') |
|
|
|
manifesto = manifesto.lower() |
|
|
|
words = manifesto.split(' ') |
|
|
|
|
|
|
|
# Divide words into three lists |
|
|
|
shortwords = [] |
|
|
|
mediumwords = [] |
|
|
|
longwords = [] |
|
|
|
for word in words: |
|
|
|
if len(word) < 4: |
|
|
|
shortwords.append(word) |
|
|
|
elif 4 <= len(word) <= 7: |
|
|
|
mediumwords.append(word) |
|
|
|
else: |
|
|
|
longwords.append(word) |
|
|
|
print(shortwords) |
|
|
|
line = (random.choice(shortwords), |
|
|
|
random.choice(mediumwords), |
|
|
|
random.choice(longwords)) |
|
|
|
result = " ".join(line) |
|
|
|
return result |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|