Sentiment Analysis
API Documentation for Sentiment Analysis
Identifying sentiment expressed in text whether they’re negative, neutral, or positive.
Group |
---|
Negative |
Neutral |
Positive |
Identifying sentiment expressed in text
POST https://apis.aigen.online/ainlp/sentiment/v1
Request Body
Name | Type | Description |
---|---|---|
text* | String |
- 200: OK Successful response
- 400: Bad Request
{
"group_count": 1,
"group_detail": [
{
"group_name": "Positive",
"rank": 1,
"score": 0.82
}
],
"status": "success"
}
{
"status": "fail"
}
Example code
- Python
- Nodejs
import requests
import json
api = "https://apis.aigen.online/ainlp/sentiment/v1"
headers = {"x-aigen-key": "<key>", "content-type": "application/json"}
data = json.dumps({"text": "ai สามารถช่วยแก้ปัญหาต่าง ๆ ได้"})
res = requests.post(api, data=data, headers=headers)
print(res.json())
const axios = require("axios");
const api = "https://apis.aigen.online/ainlp/sentiment/v1";
const headers = {
"x-aigen-key": "<key>",
};
const data = { text: "ai สามารถช่วยแก้ปัญหาต่าง ๆ ได้" };
axios
.post(api, data, { headers: headers })
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.error(err.response.data);
});