【问题标题】:LUIS Add Utterance in code JSON POST failingLUIS 在代码 JSON POST 中添加话语失败
【发布时间】:2018-02-02 10:51:17
【问题描述】:

按照这个例子:

https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-quickstart-cs-add-utterance

我正在尝试向我的 LUIS 应用发送话语。 它继续失败并显示此响应消息:

{
  "error": {
    "code": "BadArgument",
    "message": "Failed to parse example labeling objects. Parameter name: exampleLabelObjects"
  }
}

我的输入正文是:

{
  "text": "hi, what can I help you with?",
  "intentName": "Help",
  "entityLabels": []
}

如果您发送的话语没有任何实体标签,那么根据链接也是正确的。

entityLabels 字段是必需的。如果您不想标记任何 实体,请提供一个空列表,如下例所示:

[
    {
        "text": "go to Seattle",
        "intentName": "BookFlight",
        "entityLabels": [
            {
                "entityName": "Location::LocationTo",
                "startCharIndex": 6,
                "endCharIndex": 12
            }
        ]
    },
    {
        "text": "book a flight",
        "intentName": "BookFlight",
        "entityLabels": []
    }
]

构建对象的C#如下:

public class LUISUtterItem
    {
        public string utterances;
        public string text;
        public string intentName;
        public List<exampleLabelObjects> entityLabels;

    }

    public class exampleLabelObjects
    {
        public string entityName;
        public int startCharIndex;
        public int endCharIndex;
    }

我称之为:

LUISUtterItem itm = new LUISUtterItem(); 

            //itm.utterances = materialArray[1];
            itm.text = materialArray[1];
            itm.intentName = materialArray[2];
            itm.entityLabels = new List<exampleLabelObjects>();

我也尝试过不包含“entityLabels”对象,以及刚刚以相同结果启动的字符串列表。

我们将不胜感激。

【问题讨论】:

    标签: c# json azure-language-understanding


    【解决方案1】:

    所以看起来你必须在正文中包含的所有内容都是围绕它的“[]”并且它起作用了:

    [{
      "text": "hi, what can I help you with?",
      "intentName": "Help",
      "entityLabels": []
    }] 
    

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。通过发送正文来解决: { “文本”:“嗨”, “intentName”:“问候” }

      entityLabel 如果不需要就不要放。

      【讨论】:

        猜你喜欢
        • 2018-07-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-22
        • 1970-01-01
        • 1970-01-01
        • 2018-01-26
        • 1970-01-01
        相关资源
        最近更新 更多