我有一个与 LUIS 连接的聊天机器人,我知道虽然对话只会进入具有最高匹配意图的对话,但我仍然想显示其余意图的分数,有没有办法要做到这一点? 我已经有了
[LuisModel("XXXX", "XXXX", Verbose = true)]
到目前为止,这是我正在使用的:
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
string allIntents = "";
//Loop throught all intents found in JSON
foreach (var foundIntent in result.Intents)
{
allIntents += ("Intent: " + foundIntent.Intent + "\n\n" + "Score: " + foundIntent.Score + "\n\n");
}
await context.PostAsync(allIntents);
context.Wait(this.MessageReceived);
}
我的 JSON 是这样的
{
"query": "hey there",
"topScoringIntent": {
"intent": "None",
"score": 0.17292054
},
"intents": [
{
"intent": "None",
"score": 0.17292054
},
{
"intent": "intentSearch",
"score": 0.122199811
},
{
"intent": "fromIntent",
"score": 0.0327471271
},
{
"intent": "goWithIntent",
"score": 0.010828237
}
],
"entities": []
}
但是我的机器人只会返回无意图及其分数。有没有办法返回对话框中的所有意图?
编辑:答案在某种程度上对新项目有效,我不知道为什么
最佳答案
您必须像这样在您的 LuisModelAttribute 中将详细标志设置为 true:
[LuisModel("e7a9c2d5-0b92-47d3-9d73-xxxxxxxxxxxx",
"4941fa348c49494db1e8e8xxxxxxxxxx", Verbose = true)]
这是获取所有意图的代码,您可以从中获取分数
[LuisIntent("greeting")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
string allIntents = "";
//Loop throught all intents found in JSON
foreach (var foundIntent in result.Intents)
{
allIntents += ("Intent: " + foundIntent.Intent + "\n\n" + "Score: " + foundIntent.Score + "\n\n");
}
await context.PostAsync(allIntents);
context.Wait(this.MessageReceived);
}
关于C# LUIS Chatbot 从 LuisResult 中提取所有意图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47684559/