When the robot apocalypse arrives, don’t be surprised if the machines crack jokes about our undoing.

In a new research project, Microsoft has attempted to teach comedic values to computers. Using the New Yorker’s cartoon contest as fodder, the researchers came up with an algorithm to pick the funniest captions from thousands of reader submissions.

As Bloomberg reports, the results might actually be of assistance to the New Yorker’s editors, who receive roughly 5,000 caption contest entries every week. The algorithm was able to match the editors' choices a fair amount: "On average...all of the editors' favorites appeared in the AI's top 55.8 percent of choices," the Bloomberg story cited. In other words, computer assistance could cut the editors’ work down by nearly half.

Why this matters: Microsoft isn’t just doing this for hyuks. The ability for a computer to recognize humor could be important for programs like Skype Translator, which uses machine learning to help people converse across languages. Down the road, Microsoft hopes it could offer artificial intelligence with a real sense of humor—one that goes beyond Cortana’s canned jokes .

Teaching punchlines to machines

Figuring out what was funny involved asking humans to break down the visual properties of each cartoon, and to judge the humor of some corresponding captions. Microsoft’s researchers then came up an algorithm that could identify the key words or phrases in each caption. Humor scores were based on several factors, such as the length of the joke (fewer words tend to be funnier), the location of the punchline (later is better), and the similarities to the content of the image.

The algorithm, while fairly effective, did have some blind spots. Proper nouns, for instance, tend to be penalized, but that in turn punished good jokes that riffed on current events. The algorithm also failed to recognize certain expressions, and didn’t understand the importance of capitalizing certain words (such as “Him” as a reference to God.)

Perhaps for those reasons, the New Yorker isn’t quite ready to deploy Microsoft’s algorithms. Editor Bob Mankoff told Bloomberg that the system wasn’t accurate enough for his liking, and wondered if a machine could ever truly replicate a human sense of humor. Comedy, after all, is something that continues to be invented and transformed. It’s unclear if our robot overlords will be able to carry on the tradition.