在 API 控制台中使用自定义术语列表进行审查Moderate with custom term lists in the API console

Azure 内容审查器中的默认全局术语列表足以满足大多数内容审查需求。The default global list of terms in Azure Content Moderator is sufficient for most content moderation needs. 但是,可能需要屏蔽特定于组织的术语。However, you might need to screen for terms that are specific to your organization. 例如,可能需要标记竞争对手的名称作进一步审查。For example, you might want to tag competitor names for further review.

使用列表管理 API来创建要供文本审查 API 使用的自定义术语列表。Use the List Management API to create custom lists of terms to use with the Text Moderation API. “文本 - 筛选”操作扫描文本中是否存在侮辱性内容,并将文本与自定义黑名单和共享黑名单进行对比。The Text - Screen operation scans your text for profanity, and also compares text against custom and shared blacklists.

Note

最多只能使用 5 个术语列表,每个列表不超过 10,000 条术语。There is a maximum limit of 5 term lists with each list to not exceed 10,000 terms.

可使用列表管理 API 执行以下任务:You can use the List Management API to do the following tasks:

  • 创建列表。Create a list.
  • 向列表添加术语。Add terms to a list.
  • 针对列表中的术语屏蔽术语。Screen terms against the terms in a list.
  • 从列表中删除术语。Delete terms from a list.
  • 删除列表。Delete a list.
  • 编辑列表信息。Edit list information.
  • 筛选索引,使新的扫描中包含列表更改项。Refresh the index so that changes to the list are included in a new scan.

使用 API 控制台Use the API console

需要提供订阅密钥才能在联机控制台中试运行 API。Before you can test-drive the API in the online console, you need your subscription key. 此密钥位于“设置”选项卡的“Ocp-Apim-Subscription-Key”框中。This key is located on the Settings tab, in the Ocp-Apim-Subscription-Key box. 有关详细信息,请参阅概述For more information, see Overview.

刷新搜索索引Refresh search index

更改术语列表后,必须筛选其索引,这样后续扫描才包含所作更改。After you make changes to a term list, you must refresh its index for changes to be included in future scans. 此步骤类似于桌面上的搜索引擎(如果启用)或 Web 搜索引擎的操作,即不断刷新其索引以包含新文件或页面。This step is similar to how a search engine on your desktop (if enabled) or a web search engine continually refreshes its index to include new files or pages.

  1. 术语列表管理 API 参考的左侧菜单中,选择“术语列表”,然后选择“刷新搜索索引”。In the Term List Management API reference, in the left menu, select Term Lists, and then select Refresh Search Index.

    “术语列表 - 刷新搜索索引”页随即打开。The Term Lists - Refresh Search Index page opens.

  2. 对于“开放 API 测试控制台”,选择最能描述你所在位置的区域。For Open API testing console, select the region that most closely describes your location.

    “术语列表 - 刷新搜索索引”页面上的区域选择

    “术语列表 - 刷新搜索索引”API 控制台随即打开。The Term Lists - Refresh Search Index API console opens.

  3. 在 listId 框中,输入列表 ID。In the listId box, enter the list ID. 输入订阅密钥,再选择“发送”。Enter your subscription key, and then select Send.

    “术语列表 API - 刷新搜索索引”控制台响应内容框

创建术语列表Create a term list

  1. 转到术语列表管理 API 参考Go to the Term List Management API reference.

    “术语列表 - 创建”页随即打开。The Term Lists - Create page opens.

  2. 对于“开放 API 测试控制台”,选择最能描述你所在位置的区域。For Open API testing console, select the region that most closely describes your location.

    “术语列表 - 创建”页面上的区域选择

    “术语列表 - 创建”API 控制台随即打开。The Term Lists - Create API console opens.

  3. 在“Ocp-Apim-Subscription-Key”框中,输入订阅密钥。In the Ocp-Apim-Subscription-Key box, enter your subscription key.

  4. 在“请求正文”框中,输入 Name 的值(例如 MyList)和说明。In the Request body box, enter values for Name (for example, MyList) and Description.

    “术语列表 - 创建”控制台上的请求正文名称和说明

  5. 使用键/值对占位符向列表分配更具描述性的元数据。Use key-value pair placeholders to assign more descriptive metadata to your list.

    {
       "Name": "MyExclusionList",
       "Description": "MyListDescription",
       "Metadata": 
       {
          "Category": "Competitors",
          "Type": "Exclude"
       }
    }
    

    添加列表元数据作为键/值对,而不是添加实际术语。Add list metadata as key-value pairs, and not actual terms.

  6. 选择“发送”。Select Send. 列表已创建。Your list is created. 请注意,ID 值与新的列表相关联。Note the ID value that is associated with the new list. 需在其他术语列表管理功能中使用此 ID。You need this ID for other term list management functions.

    “术语列表 - 创建”控制台上的响应内容框中显示列表 ID

  7. 向 MyList 添加术语。Add terms to MyList. 在左侧菜单的“术语”下,选择“添加术语”。In the left menu, under Term, select Add Term.

    “术语 - 添加术语”页面随即打开。The Term - Add Term page opens.

  8. 对于“开放 API 测试控制台”,选择最能描述你所在位置的区域。For Open API testing console, select the region that most closely describes your location.

    “术语 - 添加术语”页面上的区域选择

    “术语 - 添加术语”API 控制台随即打开。The Term - Add Term API console opens.

  9. 在 listId 框中,输入所生成的列表 ID,再选择语言的值。In the listId box, enter the list ID that you generated, and select a value for language. 输入订阅密钥,再选择“发送”。Enter your subscription key, and then select Send.

    “术语 - 添加术语”控制台查询参数

  10. 要验证确保已向列表添加术语,请在左侧菜单中选择“术语”,然后选择“获取所有术语”。To verify that the term has been added to the list, in the left menu, select Term, and then select Get All Terms.

    “术语 - 获取所有术语”API 控制台随即打开。The Term - Get All Terms API console opens.

  11. 在 listId 框中,输入列表 ID,然后输入订阅密钥。In the listId box, enter the list ID, and then enter your subscription key. 选择“发送”。Select Send.

  12. 在“响应内容”框中,验证所输入的术语。In the Response content box, verify the terms you entered.

    “术语 - 获取所有术语”控制台上的“响应内容”框中列出了所输入的术语

  13. 再添加几条术语。Add a few more terms. 现在,你已创建了自定义术语列表,接着请尝试使用自定义术语列表扫描一些文本Now that you have created a custom list of terms, try scanning some text by using the custom term list.

删除术语和列表Delete terms and lists

删除术语或列表非常简单。Deleting a term or a list is straightforward. 使用 API 执行以下任务:You use the API to do the following tasks:

  • 删除术语。Delete a term. (术语 - 删除)(Term - Delete)
  • 删除列表中的所有术语而不删除列表。Delete all the terms in a list without deleting the list. (术语 - 删除所有术语)(Term - Delete All Terms)
  • 删除列表及其所有内容。Delete a list and all of its contents. (术语列表 - 删除)(Term Lists - Delete)

下例删除一个术语。This example deletes a single term.

  1. 术语列表管理 API 参考的左侧菜单中,选择“术语”,然后选择“删除”。In the Term List Management API reference, in the left menu, select Term, and then select Delete.

    “术语 - 删除”随即打开。The Term - Delete opens.

  2. 对于“开放 API 测试控制台”,选择最能描述你所在位置的区域。For Open API testing console, select the region that most closely describes your location.

    “术语 - 删除”页面上的区域选择

    “术语 - 删除”API 控制台随即打开。The Term - Delete API console opens.

  3. 在 listId 框中,输入要从中删除术语的列表的 ID。In the listId box, enter the ID of the list that you want to delete a term from. 此 ID 是一个数字(本例中为 122),它是“术语列表 - 获取详细信息”控制台中针对 MyList 返回的内容。This ID is the number (in our example, 122) that is returned in the Term Lists - Get Details console for MyList. 输入术语,再选择一种语言。Enter the term and select a language.

    “术语 - 删除”控制台查询参数

  4. 输入订阅密钥,再选择“发送”。Enter your subscription key, and then select Send.

  5. 要验证术语是否已删除,请使用“术语列表 - 获取所有术语”控制台。To verify that the term has been deleted, use the Term Lists - Get All console.

    “术语列表 - 获取所有术语”控制台中的“响应内容”框显示术语已删除

更改列表信息Change list information

可编辑列表的名称和说明,还可添加元数据项。You can edit a list’s name and description, and add metadata items.

  1. 术语列表管理 API 参考的左侧菜单中,选择“术语列表”,然后选择“更新详细信息”。In the Term List Management API reference, in the left menu, select Term Lists, and then select Update Details.

    “术语列表 - 更新详细信息”页随即打开。The Term Lists - Update Details page opens.

  2. 对于“开放 API 测试控制台”,选择最能描述你所在位置的区域。For Open API testing console, select the region that most closely describes your location.

    “术语列表 - 更新详细信息”页上的区域选择

    “术语列表 - 更新详细信息”API 控制台随即打开。The Term Lists - Update Details API console opens.

  3. 在 listId 框中,输入列表 ID,然后输入订阅密钥。In the listId box, enter the list ID, and then enter your subscription key.

  4. 在“请求正文”框中进行编辑,然后选择“发送”。In the Request body box, make your edits, and then select Send.

    “术语列表 - 更新详细信息”控制台上的请求正文编辑

后续步骤Next steps

要与应用程序集成,请在代码中使用 REST API,或通过术语列表 .NET 快速入门开始。Use the REST API in your code or start with the Term lists .NET quickstart to integrate with your application.