【发布时间】:2018-04-22 22:56:04
【问题描述】:
[LuisIntent("")]属性使用ILuisService查询 LUIS 基于 LUISModel 属性的值,然后找出 得分最高的意图并匹配 IntentHandler 代表 重写 MessageRecievedAsync 方法并加载 LUISResult 在调试继承自 LuisDialog 的类时动态地在以下方法中。
public async Task None(IDialogContext context, LuisResult result)
{
//some stuff
}
我的问题是如何制作一个自定义属性,将其映射到正确的意图处理程序。
我正在尝试使用 RASA NLU 服务作为我的 NLP 引擎以及 C# 中的 Microsoft Bot Framework。
我正在尝试将我从查询 RASA NLU 以获取 LUISResult 类型 JSON 的 HttpClient.GetAsync() 方法获得的 LUISEmulatedResult 映射到遵循此委托的方法。
我的进展:
[RASAIntentAttribute("IntentName")]
using Microsoft.Bot.Builder.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace DemoFlightRASA.Models
{
public class RASAIntentAttribute : Attribute
{
private readonly string _intentName;
public RASAIntentAttribute(string IntentName)
{
this._intentName = IntentName;
}
//The intent handler delegate
//Now I want to map LUISEmulatedResult which I get from HttpClient.GetAsync() method to a method which follows this delegate
public delegate Task RASAIntentHandler(IDialogContext context, LUISEmulatedResult result);
}
}
LUISEmulatedResult 模型类:
namespace DemoFlightRASA.Models
{
public class LUISEmulatedResult
{
public string query { get; set; }
public Topscoringintent topScoringIntent { get; set; }
public Intent[] intents { get; set; }
public Entity[] entities { get; set; }
}
public class Topscoringintent
{
public string intent { get; set; }
public float score { get; set; }
}
public class Intent
{
public string intent { get; set; }
public float score { get; set; }
}
public class Entity
{
public string entity { get; set; }
public string type { get; set; }
public int startIndex { get; set; }
public int endIndex { get; set; }
public Resolution resolution { get; set; }
public float score { get; set; }
}
public class Resolution
{
public string[] values { get; set; }
}
}
Also I tried this one, but this doesn't seem to work
我想在机器人框架中创建一个使用 RASA NLU 与 LUIS 相对的端到端流程。我已经准备好 RASA NLU 端点,只是无法创建 RASAIntentAttribute。
任何关于如何将委托映射到方法的指针、提示、教程、代码 sn-ps 将不胜感激。谢谢。
【问题讨论】:
-
你检查过 LuisIntent 的代码以及它是如何工作的吗?
-
LuisDialog 的代码可以在这里找到:github.com/Microsoft/BotBuilder/blob/…
-
是的,我看到了它是如何工作的,但我在某些时候卡住了。就像如何将委托 RASAIntentHandler 映射到 LUISResult。我对它是如何映射的感到困惑。任何指针都会有所帮助
标签: c# delegates attributes botframework rasa-nlu