简体   繁体   中英

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

Good afternoon.

I've trained a LUIS app to recognize specific names from a list of synonyms (Entity type: List). For example, the normalized value for ["ada", "aDa", "lovelace"] is "Ada Lovelace" .

I'm using the Enterprisebot demo as a starting point to my app, and it works like a charm. Problem is, I can't retrieve the normalized value (aka. one of its Resolution) from my query.

The API is doing fine. The problem is that the Microsoft.Bot.Builder.Luis package puts the resolutions inside a IDictionary < string, object > structure.

For example, the API correctly identifies the following entity:

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

But when I try to access its resolution, I can't read the Value field from the IDictionary pair.

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'

I've tried enttt.Resolution.Values.First() as well, but to the same result.

How do I access the first "value", so I can retrieve the normalized value "Ada Lovelace" ?
There is no string IDictionary.Get(string key) method as far as I could tell, or is there?

使用以下内容:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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