Emotion
This model tries to determine the emotion conveyed by the writer on a text, using Ekman's list of emotions as potential results.
Although detecting emotion can be very subjective, this model could find patterns after analyzing over 210,000 samples of labeled text of comments made on social media.
Prediction labels
Limits
The maximum length accepted is 512 characters.
Emotion | Emoji | Example |
---|---|---|
anger | ๐ | Oh, how DARE you discuss this in public? |
joy | ๐ฅณ | Sheโs like a kewpie doll with them. Precious. |
disgust | ๐คข | That is odd. |
fear | ๐จ | Hahaha, ok. I was worried there for a second |
sadness | ๐ | You got banned for participating in a brigade. |
surprise | ๐ฎ | Oh whoops, I misread the original comment |
neutral | ๐ | Let me give you a hint: THEY PLAY IN BOSTON! |
Invokation
- cURL
- Python
- PHP
curl -L -G 'http://api.textkit.ai/detect/emotion' \
--data-urlencode 'text=yeah, man! Go!' \
--header 'X-API-Key: your_api_key_here'
import requests
url = "https://api.textkit.ai/detect/emotion?text=yeah, man! Go!"
payload={}
headers = {
'X-API-Key': 'your_api_key_here'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
$curl = curl_init();
$url = "https://api.textkit.ai/detect/language?text=" . urlencode("yeah, man! Go!");
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
{
"prediction": {
"emotion": "joy",
"emoji": "๐ฅณ"
},
"confidence": "0.577",
"time_ms": 989
}
Field | Meaning |
---|---|
prediction | The predicted label. See above for reference |
confidence | Value between 0 and 1 that indicates how confident the model is |
time_ms | Time in milliseconds the model took to predict the label. It does not account for the network round trip time between request and response |