When Marco Rubio malfunctioned and spouted virtually the same line four times during the New Hampshire Republican Primary debate, he became the butt of a lot of robot jokes. The clips went viral and the damage to the Florida senator’s campaign was profound, as he managed only a fifth place finish in the New Hampshire primary. The knock on Rubio was that he seemed pre-programmed, but perhaps he’s just ahead of his time.

The truth is that we’re only years away from artificial intelligence becoming the fount of political rhetorical. Candidates aren’t reciting robot-written speeches yet, but that might not be the worst idea. When Chris Christie pointed out Rubio’s “robotic” performance, he was actually pointing out a very human failure.

No one knows this better than Valentin Kassarnig, a graduate student at the University of Massachusetts, Amherst. Kassarnig has developed an A.I. program capable of writing political speeches. And, let’s be clear, the speeches are good. If one debuted on the stump, the crowd would not notice.

In order to create an automated William Safire, Kassarnig fed his algorithm a database of 4,000 political speeches given on the floor of Congress throughout 2005. His program parsed through 50,000 sentences — specifically keeping track of every phrase made of six or more words and tabulating how often those phrases occurred in speeches.

“Based on that information,” he says, “I created a probabilistic model which allows me to obtain for every five-word-phrase the probability of seeing a certain word after that phrase.” In practice, that means when the algorithm sees the five-word phrase “in the United States of” it knows the next word should likely be “America,” not “Unicorns.” Kassarnig further parsed the language by looking for what he calls “Hot Topics,” three-word phrases with a specific part-of-speech pattern.

Those “hot” topics, of course, are pretty easy to predict. Republicans are more likely to go off about religious freedom, guns rights, and the armed forces. Democrats will spend more time going on about poverty, environmental issues, and income inequality. The algorithm doesn’t care, but it can put together sentences based on these patterns — joining grammatical roles (nouns, verbs, adjectives, etc.) together in coherent order.

Here’s an example of robotic “Democratic” speechifying complete with subtly powerful accusations of hypocrisy:

“The gentleman is absolutely right. The amazing thing to me when I was listening to the Republicans in the last hour is when they were trying to make the analogy to their households and talking about their kids. And one of the most significant broken promises is in the area of making higher educational opportunities more available to minority and low-income students. I am so proud of the fact that every Iraqi school child on the opening day of school had received a book bag with the seal of the U.S., pencils, pads, all kinds of things, free of charge. I had just come back from Iraq, and they had been there on the first day of this new Congress, the Republican majority is publicly demonstrating what has been evident for some time, and that is its arrogance, its pettiness, its shortsighted focus on their political life rather than to decide how we are each of us fit to govern. Here is the thing.”

It’s not great, but you kind of see the overall threads that are so familiar of a characteristic political speech. Here’s another shot:

“For years, honest but unfortunate consumers have had the ability to plead their case to come under bankruptcy protection and have their reasonable and valid debts discharged. The way the system is supposed to work, the bankruptcy court evaluates various factors including income, assets, and debt to determine what debts can be paid and how consumers can get back on their feet. Stand up for growth and opportunity. Pass this legislation.”

Sure, it’s a bit vacuous, but therein lies the verisimilitude. Still, there are limitations. “It can only produce phrases which it has seen already,” Kassarnig says. “That means, every phrase (sequence of six words) appeared already in a previous speech. Thus, the algorithm is not capable of producing ‘new’ content.”

Moreover, when a new speech is generated, “the algorithm doesn’t care about the topic in the beginning.” The program will, however, push forward a topic it may have randomly introduced in the first few sentences and make that the central focus — or at the very least, refrain from jumping around between different themes.

Is this the future of political speeches? Not exactly, but it’s indicative of the potential use of algorithms as political hacks. It’s not unthinkable that future speechwriters might simply a few thousand lines of code able to draft up a few thousand words in just seconds. Did the voters really object to Rubio because they thought he was acting like a robot? No. They objected because they thought he was acting like a politicians. Robots don’t do that. Robots are better than that.

Photos via NASA