|
@ -1,3 +1,4 @@ |
|
|
|
|
|
import random |
|
|
def poetry(): |
|
|
def poetry(): |
|
|
filename = '2013_Wages_for_Facebook_[EN].txt' |
|
|
filename = '2013_Wages_for_Facebook_[EN].txt' |
|
|
path = './manifestos/'+filename |
|
|
path = './manifestos/'+filename |
|
@ -6,7 +7,22 @@ def poetry(): |
|
|
manifesto = manifesto.replace('\n', ' ') |
|
|
manifesto = manifesto.replace('\n', ' ') |
|
|
manifesto = manifesto.lower() |
|
|
manifesto = manifesto.lower() |
|
|
words = manifesto.split(' ') |
|
|
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 |
|
|
return result |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|