Emoji tray
An entire range of emojis available on a keyboard Getty Images

If you have a hard time identifying when someone is being sarcastic on Twitter, chances are there’s an algorithm better at it than you are. The algorithm called DeepMoji, created at the Massachusetts Institute of Technology, was originally trained to analyze tweets but can now detect the emotions conveyed through those tweets by examining emoji use.

The goal was to create an algorithm that could better recognize racist tweets, reported MIT Technology Review. The developers working on it realized that there was frequently text that could only be fully understood by also understanding the sarcasm.

Read: 'The Emoji Movie' Lost Its Zero Percent Rotten Tomatoes Score

The researchers then used emoji in tweets as a way to label and categorize various emotions. By first using emoji to help the system learn how emotions were represented in tweets the same approach was then used to identify sarcasm. To teach the algorithm to recognize the slight deviations in data and the meaning in each tweet the developers use deep learning. The technique uses a large simulated network to teach patterns.

The researchers, Iyad Rahwan, associate professor at MIT and Bjarke Felbo, a student at MIT, worked to train the algorithm together. They collected 55 billion tweets to narrow down to 1.5 billion to use for training. First they worked on getting the algorithm to predict emoji use for tweets that expressed humor or sadness among other emotions.

The next step was to teach the system to identify sarcasm and the researchers found that the algorithm that had been trained to identify emotions through emoji use was better at predicting the sarcasm as well. When the accuracy was compared to that of human volunteers for sarcasm detection, the researchers found that the algorithm was correct 82 percent of the time while humans were only correct 76 percent of the time, reported MIT Tech Review.

Read: World Emoji Day: Best Apps To Download, Breastfeeding, Zombie Emojis Announced By Apple

Anyone can currently go to the DeepMoji website to type in a message and see the emoji the algorithm predicts best to fit the message. It’s pretty spot on, typing in “Thank god it’s Friday” resulted in the clapping hands emoji, the smiling emoji and praying hands emoji among others. On the site, users can also select a word to exclude it from the sentence, to see how emoji suggestion changes. The phrase “I love pizza” resulted only in heart emojis and one smiley face, but no pizza emoji. The algorithm works specifically with emotional prediction and the tweets used to teach the algorithm only used 64 of the hundreds of available emoji. So there are plenty left out, like the pizza emoji.

If you want to help improve the algorithm you can do so by annotating your own “tweets” or phrases on the site. This allows the researchers to know what emotions you would choose to attach to your own tweets rather than someone else analyzing them.