添加实体以提取数据Add entities to extract data

创建实体,以便从语言理解 (LUIS) 应用的用户话语中提取关键数据。Create entities to extract key data from user utterances in Language Understanding (LUIS) apps. 客户端应用程序使用提取的实体数据来满足客户请求。Extracted entity data is used by your client application to fullfil customer requests.

实体表示要提取的话语中的字词或短语。The entity represents a word or phrase inside the utterance that you want extracted. 实体描述与意向相关的信息,它们有时对于应用执行任务至关重要。Entities describe information relevant to the intent, and sometimes they are essential for your app to perform its task. 在将示例话语添加到意向或将示例话语添加到意向之外(之前或之后)时,可以创建实体。You can create entities when you add an example utterance to an intent or apart from (before or after) adding an example utterance to an intent.

规划实体,然后创建并进行标记Plan entities, then create and label

可以通过示例话语创建计算机学习实体,也可以通过“实体”页创建计算机学习实体。machine-learning entities can be created from the example utterances or created from the Entities page.

通常,最佳做法是在门户中创建机器学习实体之前,先花费一定时间来规划实体。In general, a best practice is to spend time planning the entities before creating a machine-learning entity in the portal. 然后,通过示例话语文本创建机器学习实体,并在子实体和特征中包含尽可能多的当时已知的详细信息。Then create the machine-learning entity from the example utterance with as much detail in the subentities and features you know at the time. 可分解实体教程演示了如何使用此方法。The decomposable entity tutorial demonstrates how to use this method.

在规划实体的过程中,可能会需要文本匹配实体(例如预生成的实体、正则表达式实体或列表实体)。As part of planning the entities, you may know you need text-matching entities (such as prebuilt entities, regular expression entities, or list entities). 可以从“实体”页面创建它们,然后在示例话语中标记它们。You can create these from the Entities page before they are labeled in example utterances.

标记时,你可以标记单个实体,然后生成为父级机器学习实体。When labeling, you can either label individual entities then build up to a parent machine-learning entity. 或者,你可以从父级机器学习实体开始,然后分解为子实体。Or you can start with a parent machine-learning entity and decompose into child entities.

提示

标记可能指示实体的所有字词,即使在客户端应用程序中提取后未使用这些单词。Label all words that may indicate an entity, even if the words are not used when extracted in the client application.

何时创建实体When to create an entity

规划实体后,应创建你的机器学习实体和子实体。After planning your entities, you should create your machine-learning entities and subentities. 这可能需要添加预生成实体或文本匹配实体,来为你的机器学习实体提供功能。This may require adding prebuilt entities or text-matching entities to provide features for your machine-learning entities. 这一切应在进行标记之前完成。These should all be done before labeling.

一旦开始标记示例话语,就可以创建机器学习实体或扩展列表实体。Once you begin labeling example utterances, you can create machine learned entities or extend list entities.

使用下表了解在何处创建或如何将每种实体类型添加到应用。Use the following table to understand where to create or add each entity type to the app.

实体类型Entity type LUIS 门户中可在哪里创建实体Where to create entity in the LUIS portal
机器学习实体machine-learning entity 实体或意图详细信息Entities or Intent detail
列表实体List entity 实体或意图详细信息Entities or Intent detail
正则表达式实体Regular expression entity 实体Entities
Pattern.any 实体Pattern.any entity 实体Entities
预生成实体Prebuilt entity 实体Entities
预生成域实体Prebuilt domain entity 实体Entities

可以从“实体”页创建所有实体,也可以在“意向详细信息”页上的示例话语中,在标记实体的过程中创建多个实体 。You can create all the entities from the Entities page, or you can create a couple of the entities as part of labeling the entity in the example utterance on the Intent detail page. 只能在“意向详细信息”页上的示例话语中标记实体。You can only label an entity in an example utterance from the Intent detail page.

如何创建新的自定义实体How to create a new custom entity

此过程适用于计算机学习实体、列表实体和正则表达式实体。This process works for machine learned entities, list entities, and regular expression entities.

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.
  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.
  3. 选择“实体”页。Select the Entities page.
  4. 选择“+ 创建”,然后选择实体类型。Select + Create , then select the entity type.
  5. 继续配置实体,并在完成后选择“创建”。Continue configuring the entity then select Create when you are done.

创建机器学习实体Create a machine learned entity

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在“生成”部分的左侧面板中选择“实体”,然后选择“+ 创建” 。From the Build section, select Entities in the left panel, and then select + Create .

  4. 在“创建实体类型”对话框中,输入实体名称,然后选择“机器学习”,然后选择 。In the Create an entity type dialog box, enter the name of the entity and select Machine learned , select. 若要添加子实体,请选择“添加结构”。To add subentities, select Add structure . 选择“创建” 。Select Create .

    创建机器学习实体的屏幕截图。Screenshot of creating a machine learned entity.

  5. 在“添加子实体”中,通过选择父实体行上的“+”添加子实体 。In Add subentities , add a subentity by selecting the + on the parent entity row.

    添加实体的屏幕截图。Screenshot of adding subentities.

  6. 选择“创建”,完成创建过程。Select Create to finish the creation process.

向机器学习实体添加功能Add a feature to a machine learned entity

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 从“生成”部分,在左侧面板中选择“实体”,然后选择机器学习实体 。From the Build section, select Entities in the left panel, and then select the machine learned entity.

  4. 通过选择实体或子实体行上的“+ 添加功能”来添加功能。Add a feature by selecting + Add feature on the entity or subentity row.

  5. 从现有实体和短语列表中选择。Select from the existing entities and phrase lists.

  6. 如果只在找到功能时才提取实体,请为该功能选择星号 *If the entity should only be extracted if the feature is found, select the asterisk, * for that feature.

    向实体添加功能的屏幕截图。Screenshot of adding feature to entity.

创建正则表达式实体Create a regular expression entity

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在“生成”部分的左侧面板中选择“实体”,然后选择“+ 创建” 。From the Build section, select Entities in the left panel, and then select + Create .

  4. 在“创建实体类型”对话框中,输入实体的名称,然后选择“RegEx”,在“Regex”字段中输入正则表达式,然后选择“创建” 。In the Create an entity type dialog box, enter the name of the entity and select RegEx , enter the regular expression in the Regex field and select Create .

    创建正则表达式实体的屏幕截图。Screenshot of creating a regular expression entity.

创建列表实体Create a list entity

列表实体表示一组固定、封闭的相关单词。List entities represent a fixed, closed set of related words. 虽然你作为作者可以更改列表,但 LUIS 不会扩大或缩小列表。While you, as the author, can change the list, LUIS won't grow or shrink the list. 还可以使用列表 entity .json 格式导入到现有列表实体。You can also import to an existing list entity using a list entity .json format.

下面的列表演示规范名称和同义词。The following list demonstrates the canonical name and the synonyms.

颜色 - 列表项名称Color - list item name 颜色 - 同义词Color - synonyms
红色Red 深红色、血红色、苹果色、消防车色crimson, blood, apple, fire-engine
蓝色Blue 天空蓝、钴蓝sky, cobalt
绿色Green 鲜绿色、青柠绿kelly, lime

使用过程来创建列表实体。Use the procedure to create a list entity. 创建列表实体后,不需要在意向中标记示例言语。Once the list entity is created, you don't need to label example utterances in an intent. 使用精确文本匹配列表项和同义词。List items and synonyms are matched using exact text.

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在“生成”部分的左侧面板中选择“实体”,然后选择“+ 创建” 。From the Build section, select Entities in the left panel, and then select + Create .

  4. 在“创建实体类型”对话框中,输入实体名称(例如 Colors),然后选择“列表” 。In the Create an entity type dialog box, enter the name of the entity, such as Colors and select List .

  5. 在“创建列表实体”对话框的“添加新子列表…”中,输入列表项名称(例如 Green),然后添加同义词 。In the Create a list entity dialog box, in the Add new sublist.... , enter the list item name, such as Green, then add synonyms.

    在实体详细信息页中创建颜色列表作为列表实体。Create a list of colors as a list entity in the Entity detail page.

  6. 添加完列表项和同义词后,选择“创建”。When you are finished adding list items and synonyms, select Create .

    完成对应用的一组更改后,请记得对应用进行训练。When you are done with a group of changes to the app, remember to Train the app. 请不要在一次更改后对应用进行训练。Do not train the app after a single change.

    备注

    此过程演示如何从“意向详细信息”页中的示例言语创建和标记列表实体。This procedure demonstrates creating and labeling a list entity from an example utterance in the Intent detail page. 还可以从“实体”页创建相同的实体。You can also create the same entity from the Entities page.

为实体添加角色Add a role for an entity

角色是基于上下文的实体命名子类型。A role is a named subtype of an entity, based on context.

添加角色以区分不同的上下文Add a role to distinguish different contexts

在下面的言语中,有两个位置是由其各自周围的字词(如 tofrom)在语义上进行了指定:In the following utterance, there are two locations, and each is specified semantically by the words around it such as to and from:

Pick up the package from Seattle and deliver to New York City.

在此过程中,将 origindestination 角色添加到预生成的 geographyV2 实体。In this procedure, add origin and destination roles to a prebuilt geographyV2 entity.

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在“生成”部分的左侧面板中选择“实体” 。From the Build section, select Entities in the left panel.

  4. 选择“+ 添加预生成的实体”。Select + Add prebuilt entity . 依次选择“geographyV2”、“完成” 。Select geographyV2 then select Done . 这会将预生成的实体添加到应用。This adds a prebuilt entity to the app.

    如果发现模式在包含 Pattern.any 时错误提取实体,请使用显式列表来更正此问题。If you find that your pattern, when it includes a Pattern.any, extracts entities incorrectly, use an explicit list to correct this problem.

  5. 从实体的“实体”页列表中选择新添加的预生成的 geographyV2实体。Select the newly added prebuilt geographyV2 entity from the Entities page list of entities.

  6. 要添加新角色,请选择“未添加角色”旁边的 + 。To add a new role, select + next to No roles added .

  7. 在“类型角色…”文本框中,输入角色 Origin 的名称并按 Enter。In the Type role... textbox, enter the name of the role Origin then enter. 添加 Destination 的第二个角色名称然后按 Enter。Add a second role name of Destination then enter.

    将 Origin 角色添加到 Location 实体的屏幕截图Screenshot of adding Origin role to Location entity

    该角色将添加到预生成的实体中,但不会添加到使用该实体的任何言语中。The role is added to the prebuilt entity but isn't added to any utterances using that entity.

在示例言语中使用角色来标记文本Label text with a role in an example utterance

提示

可以通过使用某个机器学习实体的子实体来进行标记的方式来替换角色。Roles can be replaced by labeling with subentities of a machine-learning entities.

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 转到“意向详细信息”页,其中包含使用该角色的示例言语。Go to the Intent details page, which has example utterances that use the role.

  4. 若要使用角色进行标记,请在示例语句中选择实体标签(文本下的实线),然后从下拉列表中选择“在实体窗格中查看”。To label with the role, select the entity label (solid line under text) in the example utterance, then select View in entity pane from the drop-down list.

    屏幕截图显示了已选中“在实体窗格中查看”菜单项。Screenshot shows the View in entity pane menu item selected.

    实体面板将在右侧打开。The entity palette opens to the right.

  5. 选择实体,然后转到面板底部并选择角色。Select the entity, then go to the bottom of the palette and select the role.

    屏幕截图显示了选择角色的位置。Screenshot shows where to select the role.

创建 pattern.any 实体Create a pattern.any entity

Pattern.any 实体仅适用于模式模式The Pattern.any entity is only available with Patterns.

不要更改实体类型Do not change entity type

LUIS 不允许更改实体类型,因为它不知道构造该实体要添加或删除的内容。LUIS does not allow you to change the type of the entity because it doesn't know what to add or remove to construct that entity. 若要更改类型,最好创建一个名称稍微不同的、类型正确的新实体。In order to change the type, it is better to create a new entity of the correct type with a slightly different name. 实体创建后,在每句话语中,删除旧标记实体名称并添加新的实体名称。Once the entity is created, in each utterance, remove the old labeled entity name and add the new entity name. 重新标记所有话语后,即可删除旧实体。Once all the utterances have been relabeled, delete the old entity.

后续步骤Next steps

了解有关以下方面的详细信息:Learn more about: