Trump meets computational linguistics

Trump orating

“I actually called her, and she never mentioned my name. You know, I - when I sold - oh, did I get a call from one of the Environmental Protection Agency, they couldn’t find it because it comes out in big globs, right, and you say to yourself, ‘How does that help us?'"

Trump is one of the most amusing orators in the history of presidential politics in the the U.S. But I wondered what would happen I took the text of a few of his speeches and fed it into a algorithm that uses Markov chains to shake things up a bit.

A Markov Chain is a process in which states undergo random transitions in which the probability of the next state depends only on the current state. This is a characteristic often called “memorylessness.” In statistical modeling, Markov Chains have serious applications. But I’ve used it here to analyze and distort Trump speeches so that they sound even more rambling than in reality. This results in such keepers as:

“Well, they couldn’t find it because then it comes out in big globs, right, and you had Iraq and you know, China comes over and they say, we can’t believe it or not. I’m doing it. Number two, I’m a free trader.

The algorithm takes a “snapshot” of the preceding two words in a sentence, scans the text for those two words, generating a table of words that follow those couplets. It then chooses a random word based on the probabilities.

“We have wounded warriors, incredible people. And you know, we are doing a big problem, Russia’s a problem, China’s a problem. We’ve got a lot of things. We are rebuilding China. We’re rebuilding many countries. The Euro, China is going to be repealed and replaced. It will die in ’17 anyway."

Some of the sentences are grammatically correct; many are not. But they have similar cadence and “feel” as a real Trump speech.

"“Mr. Trump, where are those hats made?” I said. I had no choice, because I don’t want me to refute his statement. How dare you say that. They don’t know what they’re saying — that nobody believes. So you have a presidential election coming up. We have $2 trillion and we are going to move the plant back to the ceiling, $500 billion is?"

I used a Python implementation of the Markov text generator described above. You can read the full text of a run. The source text comes from three different speeches given by Mr. Trump.