Generating text from presidential speeches

There have been dozens of presidential speeches since 9/11, and it’s interesting to study those speeches — from both Bush and Obama — because there are a few key words that have taken on loaded meanings.

The word “terrorist” implies a certain type of violent offender — especially since 9/11. And the idea of patriotism — and being “American” — has become either a point of pride, or one of shame.

So I decided to take those words and put them in a different context: marine life.

I looked at every presidential speech since 9/11, and I found every instance of the word “terrorist” and “American” when they are in the same line as the following verbs: have, is, are and who. Then I took the words following “terrorist” and “American,” and printed all of them until a period or a comma appears.

Here is the result:

—–

Mackerel

Clownfish and their state sponsors the materials

Mackerel who have lost their jobs need our help

Mackerel know economic security can vanish in an instant without health security

Mackerel are doing the work of compassion every day

Clownfish on the run

Mackerel into battle is the most profound decision a President can make
Mackerel are a resolute people who have risen to every test of our time
Mackerel are a free people
Mackerel have faith in ourselves

Clownfish who started this war

Mackerel took those dollars and put them to work

Mackerel
Mackerel have accepted the hardest duties in this cause
Mackerel have witnessed this idealism and some for the first time

Clownfish and insurgents are violently opposed to democracy

Mackerel

Mackerel make and grow

Mackerel

Mackerel cannot afford a health insurance policy

Clownfish is a reminder of the shoreless ambitions of this enemy
Clownfish

Mackerel can have confidence in the outcome of this struggle because we’re not in this struggle alone

Mackerel think their taxes are high enough
Mackerel with their own money

Mackerel is a Marine Gunnery Sergeant named William “Spanky” Gibson
Mackerel like Spanky Gibson serve on our side

Mackerel have towards their own government

Mackerel from all walks of life as well as the economy as a whole

Mackerel watching right now

Mackerel have now taken the presidential oath

Mackerel and so many others
Mackerel to work building clean energy facilities and give rebates to Mackerel who make their homes more energy efficient

Mackerel who have insurance to keep their doctor and their plan

SOURCE CODE

import sys

for line in sys.stdin:
	terrorists = line.find("terrorists")
	if terrorists != -1:
		line = line.replace("terrorists", "Clownfish")
		commacheck = line.find(",")
		periodcheck = line.find(".")
		havecheck = line.find(" have ")
		arecheck = line.find(" are ")
		ischeck = line.find(" is ")
		whocheck = line.find(" who ")
		if havecheck or arecheck or ischeck or whocheck:
			if commacheck != -1:
				if periodcheck != -1:
					period = line.index(".")
					comma = line.index(",")
					if period > comma:
						if comma > 15:
							print line[terrorists:comma]
					else:
						if period > 15:
							print line[terrorists:period]
	
	americans = line.find("Americans")
	if americans != -1:
		line = line.replace("Americans","Mackerel")
		commacheck = line.find(",")
		periodcheck = line.find(".")
		havecheck = line.find(" have ")
		arecheck = line.find(" are ")
		ischeck = line.find(" is ")
		whocheck = line.find(" who ")
		if havecheck or arecheck or ischeck or whocheck:
			if commacheck != -1:
				if periodcheck != -1:
					period = line.index(".")
					comma = line.index(",")
					if period > comma:
						if comma > 15:
							print line[americans:comma]
					else:
						if period > 15:
							print line[americans:period]

Leave a Reply