快速入门:使用浏览器获取意向Quickstart: Get intent with a browser

若要了解 LUIS 预测终结点返回的内容,请在 Web 浏览器中查看预测结果。To understand what a LUIS prediction endpoint returns, view a prediction result in a web browser.

先决条件Prerequisites

若要查询公共应用,需要:In order to query a public app, you need:

  • 自己的语言理解 (LUIS) 密钥。Your own Language Understanding (LUIS) key. 如果你没有用于创建密钥的订阅,可以注册一个试用帐户If you do not already have a subscription to create a key, you can register for a trial account. 无法使用 LUIS 创作密钥。The LUIS authoring key will not work.
  • 公共应用的 ID:df67dcdb-c37d-46af-88e1-8b97951ca1c2The public app's ID: df67dcdb-c37d-46af-88e1-8b97951ca1c2.

使用浏览器查看预测Use the browser to see predictions

  1. 打开 Web 浏览器。Open a web browser.

  2. 使用以下完整 URL(请将 YOUR-KEY 替换为自己的 LUIS 密钥)。Use the complete URLs below, replacing YOUR-KEY with your own LUIS key. 请求为 GET 请求,并包含授权和 LUIS 密钥作为查询字符串参数。The requests are GET requests and include the authorization, with your LUIS key, as a query string parameter.

    GET 终结点(按槽)请求的 V3 URL 格式为:The format of the V3 URL for a GET endpoint (by slots) request is:

    https://{region}.api.cognitive.azure.cn/luis/prediction/v3.0/apps/df67dcdb-c37d-46af-88e1-8b97951ca1c2/slots/production/predict?query=turn on all lights&subscription-key=YOUR-KEY

  3. 将该 URL 粘贴到浏览器窗口中,然后按 Enter。Paste the URL into a browser window and press Enter. 浏览器显示的 JSON 结果指示 LUIS 将 HomeAutomation.TurnOn 意向检测为首要意向,并检测到值为 onHomeAutomation.Operation 实体。The browser displays a JSON result that indicates that LUIS detects the HomeAutomation.TurnOn intent as the top intent and the HomeAutomation.Operation entity with the value on.

    {
        "query": "turn on all lights",
        "prediction": {
            "topIntent": "HomeAutomation.TurnOn",
            "intents": {
                "HomeAutomation.TurnOn": {
                    "score": 0.5375382
                }
            },
            "entities": {
                "HomeAutomation.Operation": [
                    "on"
                ]
            }
        }
    }
    
  4. 要查看所有意图,请添加相应的查询字符串参数。To see all the intents, add the appropriate query string parameter.

    show-all-intents=true 添加到查询字符串末尾可显示所有意向Add show-all-intents=true to the end of the querystring to show all intents:

    https://{region}.api.cognitive.azure.cn/luis/predict/v3.0/apps/df67dcdb-c37d-46af-88e1-8b97951ca1c2/slots/production/predict?query=turn on all lights&subscription-key=YOUR-KEY&show-all-intents=true

    {
        "query": "turn off the living room light",
        "prediction": {
            "topIntent": "HomeAutomation.TurnOn",
            "intents": {
                "HomeAutomation.TurnOn": {
                    "score": 0.5375382
                },
                "None": {
                    "score": 0.08687421
                },
                "HomeAutomation.TurnOff": {
                    "score": 0.0207554
                }
            },
            "entities": {
                "HomeAutomation.Operation": [
                    "on"
                ]
            }
        }
    }