Luis python SDK语句加法

2024-04-25 06:34:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我们正在尝试使用Luis框架和pythonsdk创建一个Chatbot,使用Azure documentation作为参考。我们已经能够添加意图,实体和预建实体使用相同的。这些更改显示在验证添加的门户上。你知道吗

但是用于添加话语的代码没有显示在门户上,也没有在终端上列出。你知道吗

def create_utterance(intent, utterance, *labels):
    """
    Add an example LUIS utterance from utterance text and a list of
    labels.  Each label is a 2-tuple containing a label name and the
    text within the utterance that represents that label.
    Utterances apply to a specific intent, which must be specified.
    """
    text = utterance.lower()

    def label(name, value):
        value = value.lower()
        start = text.index(value)
        return dict(entity_name=name, start_char_index=start,
                    end_char_index=start + len(value), role=None)

    return dict(text=text, intent_name=intent,
                entity_labels=[label(n, v) for (n, v) in labels])
utterances = [create_utterance("FindFlights", "find flights in economy to Madrid",
                               ("Flight", "economy to Madrid"),
                               ("Location", "Madrid"),
                               ("Class", "economy")),
              create_utterance("FindFlights", "find flights to London in first class",
                               ("Flight", "London in first class"),
                               ("Location", "London"),
                               ("Class", "first")),
              create_utterance("FindFlights", "find flights from seattle to London in first class",
                               ("Flight", "flights from seattle to London in first class"),
                               ("Location", "London"),
                               ("Location", "Seattle"),
                               ("Class", "first"))]

client.examples.batch(appId, appVersion, utterances, raw=True)
client.examples.list(appId, appVersion)

此代码不返回任何错误,但也不列出语句。你知道吗


Tags: totextnameinlabelsvaluecreatelocation