使用 API 主控台中的自訂字詞清單進行審核Moderate with custom term lists in the API console

Azure Content Moderator 中的預設全域字詞清單已可滿足大部分內容審核需求。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 blocklists.

注意

上限是 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 參考中,從左側功能表中選取 [Term Lists] (字詞清單)****,然後選取 [Refresh Search Index] (重新整理搜尋索引)****。In the Term List Management API reference, in the left menu, select Term Lists, and then select Refresh Search Index.

    [Term Lists - Refresh Search Index] (字詞清單 - 重新整理搜尋索引)**** 頁面隨即開啟。The Term Lists - Refresh Search Index page opens.

  2. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Term Lists - Refresh Search Index] (字詞清單 - 重新整理搜尋索引) 頁面區域選取項目

    [Term Lists - Refresh Search Index] (字詞清單 - 重新整理搜尋索引)**** API 主控台隨即開啟。The Term Lists - Refresh Search Index API console opens.

  3. 在 [listId]**** 方塊中,輸入清單識別碼。In the listId box, enter the list ID. 輸入您的訂用帳戶金鑰,然後選取 [Send] (傳送)****。Enter your subscription key, and then select Send.

    [Term Lists API - Refresh Search Index] (字詞清單 API - 重新整理搜尋索引) 主控台的 [Response content] (回應內容) 方塊

建立字詞清單Create a term list

  1. 移至字詞清單管理 API 參考Go to the Term List Management API reference.

    [Term Lists - Create] (字詞清單 - 建立)**** 頁面隨即開啟。The Term Lists - Create page opens.

  2. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [Term Lists - Create] (字詞清單 - 建立) 頁面區域選取項目

    [Term Lists - Create] (字詞清單 - 建立)**** 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. 在 [Request body] (要求本文)**** 方塊中,輸入 [Name] (名稱)**** (例如 MyList) 和 [Description] (描述)**** 的值。In the Request body box, enter values for Name (for example, MyList) and Description.

    [Term Lists - Create] (字詞清單 - 建立) 主控台的要求本文名稱和描述

  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. 您需要有此識別碼,才能進行其他字詞清單管理功能。You need this ID for other term list management functions.

    [Term Lists - Create] (字詞清單 - 建立) 主控台的 [Response content] (回應內容) 方塊顯示清單識別碼

  7. 將字詞新增至 MyList。Add terms to MyList. 在左側功能表中的 [字詞]**** 下方,選取 [新增字詞]****。In the left menu, under Term, select Add Term.

    [字詞 - 新增字詞]**** 頁面隨即開啟。The Term - Add Term page opens.

  8. 針對 [Open API testing console] (開啟 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]**** 方塊中,輸入產生的清單識別碼,並選取一個語言值。In the listId box, enter the list ID that you generated, and select a value for language. 輸入您的訂用帳戶金鑰,然後選取 [Send] (傳送)****。Enter your subscription key, and then select Send.

    [字詞 - 新增字詞] 主控台查詢參數

  10. 若要確認是否已將該字詞新增至清單,請從左側功能表中,選取 [Term] (字詞)****,然後選取 [Get All Terms] (取得所有字詞)****。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]**** 方塊中,輸入清單識別碼,然後輸入您的訂用帳戶金鑰。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. 針對 [Open API testing console] (開啟 API 測試主控台)**** 中,選取最能描述您位置的區域。For Open API testing console, select the region that most closely describes your location.

    [字詞 - 刪除] 頁面區域選取項目

    [字詞 - 刪除]**** API 主控台隨即開啟。The Term - Delete API console opens.

  3. 在 [listId]**** 方塊中,輸入要從中刪除字詞的清單識別碼。In the listId box, enter the ID of the list that you want to delete a term from. 此識別碼是 MyList [字詞清單 - 取得詳細資料]**** 主控台中傳回的數字 (在我們的範例中是 122)。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. 輸入您的訂用帳戶金鑰,然後選取 [Send] (傳送)****。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. 針對 [Open API testing console] (開啟 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]**** 方塊中,輸入清單識別碼,然後輸入您的訂用帳戶金鑰。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.