繁体   English   中英

无法从Microsoft.Bot.Builder.Luis.Models检索实体解析

[英]Unable to retrieve entity resolution from Microsoft.Bot.Builder.Luis.Models

下午好。

我已经训练了LUIS应用程序以识别同义词列表(实体类型:列表)中的特定名称。 例如, ["ada", "aDa", "lovelace"]的归一化值为"Ada Lovelace"

我将Enterprisebot演示用作我的应用程序的起点,它的工作原理很吸引人。 问题是,我无法从查询中检索归一化值(也就是其分辨率之一)。

API运行正常。 问题在于Microsoft.Bot.Builder.Luis程序包将这些解析度放入IDictionary < string, object >结构中。

例如,API正确标识以下实体:

"entities": [
        {
            "entity": "lovelace",
            "type": "Sala",
            "startIndex": 16,
            "endIndex": 23,
            "resolution": {
                "values": [
                    "Ada Lovelace"
                ]
            }
        }
    ]

但是,当我尝试访问其分辨率时,无法从IDictionary对中读取“值”字段。

Console.Write( enttt.Entity );

    // "lovelace"

Console.Write( enttt.Type );

    // "Sala"

Console.Write( enttt.Resolution );

    // System.Collections.Generic.Dictionary`2[System.String,System.Object]

Console.Write( enttt.Resolution.First() );

    // [values, System.Collections.Generic.List`1[System.Object]]

Console.Write( enttt.Resolution.First().Key );

    // "values"

Console.Write( enttt.Resolution.First().Value );

    // System.Collections.Generic.List`1[System.Object]

Console.Write( enttt.Resolution.First().Value.toString() );

    // System.Collections.Generic.List`1[System.Object]

Console.Write( enttt.Resolution.First().Value.First() );

    // object does not contain a definition for 'First'

我也尝试过enttt.Resolution.Values.First() ,但结果相同。

如何访问第一个“值”,以便检索归一化值"Ada Lovelace"
据我所知,没有string IDictionary.Get(string key)方法,或者存在吗?

使用以下内容:

var normalizedValue = result.Entities[0].Resolution.Values.Select(s => ((List<object>)s)[0]).FirstOrDefault();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM