# sentiment analysis
This interface, from the plug-in 1.1.8 Start Support
Conduct sentiment analysis to determine emotional tendencies
# to initialize
Plugin version number in the document, only for example reference, the latest version of the plugin,Subject to this
{
"pages": [
"pages/index/index"
],
"plugins": {
"chatbot": {
"version": "1.2.23",
"provider": "wx8c631f7e9f2465e1"
}
},
"requiredBackgroundModes": [
"audio"
],
"sitemapLocation": "sitemap.json"
}
var plugin = requirePlugin("chatbot")
App({
onLaunch: function () {
plugin.init({
appid: "P5Ot9PHJDechCYqDFAW1AiK6OtG3Ja", //Mini Program sample account, for learning and reference only
openid: "", //User's openid, not required, it is recommended to pass this parameter
success: () => {}, //Not required
fail: (error) => {}, //Not required
})
},
})
# Interface information
Sentiment analysis of the text, judging emotional tendencies, supports two coarse-grained labels:
- 3 Category: Positive, Negative, No Emotion
- 6 Category: Like, happy, dislike, sad, angry, no emotion
# Invoke the sentiment analysis interface
const txt = "Congrats to Chang."
plugin.api.nlp('sentiment', {q: txt, mode: '3class'}).then(nothing => {
console.log("sentiment result : ", nothing)
})
# Request parameters
field | type | describe |
---|---|---|
q | string | Input Text, UTF-8 Encoding, with a maximum length of 1024 The word |
mode(available) | string | "3class" (default) or "6class" |
# Return to Results
# 3 Category Back Results
{
"error": null,
"result": [
["Front" 0.9593541622161865],
["No emotion," 0.0400625541806221],
["Negative," 0.000583284127060324]
]
}
3 Category Emotion Label Dxplaination:
category | Introductions |
---|---|
positive | Express positive emotions |
negative | Expressing negative emotions |
No emotion | No obvious emotional tendencies |
# 6 Category Back Results
{
"error": null,
"result": [
["happy," 0.9011998772621155],
["No emotion," 0.08493703603744507],
["Like," 0.011011340655386448],
["Sorrow," 0.0015742022078484297],
["Disgust," 0.0006485909689217806],
["Anger," 0.000628964276984334]
]
}
6 Category Emotion Label Dxplaination:
category | Introductions |
---|---|
like | Positive emotions that express preferences |
happy | Express happy, happy positive emotions |
disgust | Expressing negative feelings of dislike and dislike |
sad | Express negative feelings of unhappiness and sadness |
anger | Express negative emotions of anger and anger |
No emotion | No obvious emotional tendencies |