4 ms·
Free verse seems silly and pointless. So I wrote a trivial program to turn prose into free verse: import random def poem(text, p_break=0.5, seed=1234
by csense 13y ago
Free verse seems silly and pointless. So I wrote a trivial program to turn prose into free verse:
import random
def poem(text, p_break=0.5, seed=1234):
rand = random.Random(seed)
result = []
for w in text.split():
result.append(w)
if rand.uniform(0.0, 1.0) < p_break:
result.append('\n')
else:
result.append(' ')
return "".join(result)
print poem("This is a poem written by a program. It is not really a poem because it does not rhyme, it is some weird thing called free verse, which is a poem that does not rhyme.", p_break=0.1)
Here's the output:
This is a
poem written by a program.
It is not
really a poem because it does not rhyme,
it is some
weird thing called free
verse, which is a poem that does not rhyme.
- JonnieCache 13y agohttp://en.wikipedia.org/wiki/Scansion#Elements http://en.wikipedia.org/wiki/Scansion#Elements