默认情况下,这是我们如何将文本发送到LUIS进行处理并返回意图。
[Serializable]
public class LuisDialogController : LuisDialog<FAQConversation>
{
private readonly BuildFormDelegate<FAQConversation> _newConversation;
public LuisDialogController(BuildFormDelegate<FAQConversation> newConversation) : base(new LuisService(new LuisModelAttribute(
ConfigurationManager.AppSettings["LuisAppId"],
ConfigurationManager.AppSettings["LuisAPIKey"],
domain: ConfigurationManager.AppSettings["LuisAPIHostName"])))
{
this._newConversation = newConversation;
}
[LuisIntent("None")]
public async Task NoneIntent(IDialogContext context, LuisResult result)
{
await this.ShowLuisResult(context, result);
}
}
我想知道如何以编程方式将文本发送到LUIS。
//pseudocode
var foo = new Luis();
var luisIntent = foo.processLanguage("How are you?");
switch(luisIntent)
{
case LuisIntent.Inquiry:
{
//do something; break;
}
default:
{
//do something else; break;
}
}
我一直在寻找这个solution,但是他没有给出正则表达式来回答。
这个想法可行吗?
答案 0 :(得分:1)
在“端点”列下方,您具有可以通过http GET从LUIS检索数据的网址:
https://*.api.cognitive.microsoft.com/luis/v2.0/apps/
*?subscription-key=*&verbose=true&timezoneOffset=0&q=this%20is%20test%20sentence
它将为您提供具有类似于以下内容的JSON结果:
{
"query": "this is test sentence",
"topScoringIntent": {
"intent": "None",
"score": 0.522913933
},
"intents": [
...
],
"entities": []
}
请参见more detail and sample C# code here。
或者,您可以使用:
using Microsoft.Bot.Builder.Luis;
...
var model = new LuisModel() {};
var luisService = new LuisService(model);
var result = await luisService.QueryAsync(textToAnalyze, CancellationToken.None);