It’s time to write a program to make a poem! I decided to make propaganda poetry for Reading and Writing Electronic Text. Hopefully very bad propaganda poetry.
I dug up some books from the library and compiled a text file with war slogans from World War Two posters (British and American.) I also created a text file with headlines from The Economist (always mysteriously poetic!) and threw in my corporate mottos to the mix for good measure.
I think the results are actually pretty good for being fairly nonsensical. Here are my favorite poems that were generated. (You can find the code for the program at the end of this post.)
Poem One
Relearning old lessons
we trust
All that glitters is
kill
This is the enemy.
Keep that lumber coming!
Is your trip necessary?
Grow vitamins at your kitchen door.
Just a good afternoon’s
Bad ventilation ruins ammunition.
Poem Two
Buy victory bonds. Invest.
Come into the factories.
United we are strong.
Do it! Keep ‘em firing!
The daily diary of
neighbor, State Farm is there
A few careless words
If you are bombed
Poem Three
Buy victory bonds. Invest
Stamp ‘em out! Buy
here! Unless we keep ‘em firing!
Reach out and touch
skin-deep
The attack begins in.
Leave this to us
Your metal is on.
Our fight is right.
Poem Four
Dig for victory.
firm thanks to the merchant navy.
America’s biggest guns point
it’s murder. Make ‘em pay. Keep producing.
The cat who doesn’t
taste like steakburgers.
Grow for winter as
The attack begins in.
Of course I can!
The Jap Way
Poem Five
Lend a hand on
more tanks.
Give it your best!
for the Jap
more challenging than the
Women
Grow for winter as
Bad ventilation ruins ammunition.
Of course I can!
War gardens for victory.
Poem Six
The life-line is firm
war workers please.
Save waste paper.
Good work. Keep down living costs.
Plop, plop, fizz, fiz,
a Guinness. I wish you were.
Buy victory bonds. Invest
But of course
America Calling: Take Your,
He gives 100% You
Poem Seven
The international reaction
We need to
Have it your way.
Travel interferes with the War effort.
Bayer works wonders
to them.
On fire
If it ain’t
Poem Eight
How corporate bedfellows compare
(Destroying itself from within)
SHIFT_
Have it your way.
Them. Buy war bonds.
You. Destroy syphilis.
Surrounded by sharks
Booze-free bars
Poem Nine
We want your kitchen
bombed out and have no friends to go to, ask a policeman or your warden where to find your rest centre.
Eat these every day.
Navy!
Roar, Boys, Roar It
break today
But we’ve got to
Leave this to us
Give us more of
Fast and steady speeds
The Program
Each line of the poem are the first 3-4 words of a corporate motto, war slogan (British/American), or Economist headline.
I think the random generation is pretty good. At times, I would end up liking 2-4 lines of each poem, and not caring for the rest. It seems to make more sense to combine one motto line followed by another motto line, etc. for better results. I also found using mostly war slogans in the poems returned better results. I think this is because the war slogans are short, pithy and to the point which works well when combined into poetry. Also having one source text dominate makes the poem more cohesive and not so random.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
import sys import random file1_lines = list() for line in open("americanpropaganda.txt"): line = line.strip() file1_lines.append(line) file2_lines = list() for line in open("economist.txt"): line = line.strip() file2_lines.append(line) file3_lines = list() for line in open("corporatelife.txt"): line = line.strip() file3_lines.append(line) file4_lines = list() for line in open("britishpropaganda.txt"): line = line.strip() file4_lines.append(line) random_economist_line_one = random.choice(file2_lines) random_economist_line_two = random.choice(file2_lines) random_slogan_line_three = random.choice(file3_lines) random_propaganda_line_four = random.choice(file1_lines) random_slogan_line_five = random.choice(file3_lines) random_propaganda_line_six = random.choice(file1_lines) random_economist_line_seven = random.choice(file2_lines) random_economist_line_eight = random.choice(file2_lines) random_british_slogan_one = random.choice(file4_lines) random_british_slogan_two = random.choice(file4_lines) random_propaganda_two = random.choice(file1_lines) random_propaganda_three = random.choice(file1_lines) random_economist_line_one_words = random_economist_line_one.split(" ") random_economist_line_two_words = random_economist_line_two.split(" ") random_slogan_line_three_words = random_slogan_line_three.split(" ") random_propaganda_line_four_words = random_propaganda_line_four.split(" ") random_slogan_line_five_words = random_slogan_line_five.split(" ") random_propaganda_line_six_words = random_propaganda_line_six.split(" ") random_economist_line_seven_words = random_economist_line_seven.split(" ") random_economist_line_eight_words = random_economist_line_eight.split(" ") random_british_slogan_one_words = random_british_slogan_one.split(" ") random_british_slogan_two_words = random_british_slogan_two.split(" ") random_propaganda_two_words = random_propaganda_two.split(" ") random_propaganda_three_words = random_propaganda_three.split(" ") line_one = " ".join(random_economist_line_one_words[:4]) line_two = " ".join(random_economist_line_two_words[:3]) line_three = " ".join(random_slogan_line_three_words[:3]) line_four = " ".join(random_propaganda_line_four_words[:4]) line_five = " ".join(random_slogan_line_five_words[4:]) line_six = " ".join(random_propaganda_line_six_words[:4]) line_seven = " ".join(random_economist_line_seven_words[:4]) line_eight = " ".join(random_economist_line_eight_words[:4]) line_nine = " ".join(random_british_slogan_one_words[:4]) line_ten = " ".join(random_british_slogan_two_words[:4]) line_eleven = " ".join(random_propaganda_two_words[:4]) line_twelve = " ".join(random_propaganda_three_words[4:]) print line_one + "\n" + line_two + "\n" + line_three + "\n" + line_five + "\n" + line_four + "\n" + line_six + "\n" + line_eleven + "\n" + line_twelve + "\n" + line_nine + "\n" + line_ten |