从 API 控制台审查文本Moderate text from the API console

在 Azure 内容审查器中使用文本审查 API 扫描文本内容以查找亵渎语言,并将其与自定义和共享列表进行比较。Use the Text Moderation API in Azure Content Moderator to scan your text content for profanity and compare it against custom and shared lists.

获取 API 密钥Get your API key

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

转到文本审查 API 参考Go to the Text Moderation API reference.

“文本 - 屏幕” 页随即打开。The Text - Screen page opens.

打开 API 控制台Open the API console

若要打开 API 测试控制台 ,选择最贴切地描述你所在位置的区域。For Open API testing console, select the region that most closely describes your location.

“文本 - 屏幕”页区域选择

文本 - 屏幕 API 控制台随即打开。The Text - Screen API console opens.

选择输入Select the inputs

parametersParameters

在文本屏幕中选择要使用的查询参数。Select the query parameters that you want to use in your text screen. 在本例中,使用语言 的默认值。For this example, use the default value for language. 也可以将其留空,因为作为其执行的一部分,该操作将自动检测可能的语言。You can also leave it blank because the operation will automatically detect the likely language as part of its execution.

Note

有关 language 参数,分配 eng 或留空以查看计算机辅助的分类 响应(预览功能)。For the language parameter, assign eng or leave it empty to see the machine-assisted classification response (preview feature). 此功能仅支持英语This feature supports English only.

对于不雅用语 检测,请使用本文所列的支持语言的 ISO 639-3 代码或留空。For profanity terms detection, use the ISO 639-3 code of the supported languages listed in this article, or leave it empty.

对于“自动更正” 、“PII” 和“分类(预览)” ,请选择“true” 。For autocorrect, PII, and classify (preview), select true. 将“ListId” 字段保留空白。Leave the ListId field empty.

文本 - 屏幕控制台查询参数

内容类型Content type

有关 Content-Type,选择你想要显示的内容类型。For Content-Type, select the type of content you want to screen. 在本例中,使用默认的 text/plain 内容类型。For this example, use the default text/plain content type. 在“Ocp-Apim-Subscription-Key” 框中,输入订阅密钥。In the Ocp-Apim-Subscription-Key box, enter your subscription key.

要扫描的示例文本Sample text to scan

在“请求正文” 框中,输入一些文本。In the Request body box, enter some text. 以下示例显示文本中的有意拼写错误。The following example shows an intentional typo in the text.

Note

以下示例文本中的无效社会安全号码是有意而为。The invalid social security number in the following sample text is intentional. 目的是传达示例输入和输出格式。The purpose is to convey the sample input and output format.

Is this a grabage or crap email abcdef@abcd.com, phone: 6657789887, IP: 255.255.255.255, 1 Microsoft Way, Redmond, WA 98052.
These are all UK phone numbers, the last two being Microsoft UK support numbers: +44 870 608 4000 or 0344 800 2400 or 0800 820 3300.
Also, 999-99-9999 looks like a social security number (SSN).

分析响应Analyze the response

下面的响应显示来自 API 的各种见解。The following response shows the various insights from the API. 它包含潜在不雅内容、个人数据、分类(预览)和自动更正版本。It contains potential profanity, personal data, classification (preview), and the auto-corrected version.

Note

计算机辅助的“分类”功能处于预览状态,仅支持英语。The machine-assisted 'Classification' feature is in preview and supports English only.

{"OriginalText":"Is this a grabage or crap email abcdef@abcd.com, phone: 6657789887, IP: 255.255.255.255, 1 Microsoft Way, Redmond, WA 98052.\r\nThese are all UK phone numbers, the last two being Microsoft UK support numbers: +44 870 608 4000 or 0344 800 2400 or 0800 820 3300.\r\nAlso, 544-56-7788 looks like a social security number (SSN).",
"NormalizedText":"Is this a grabage or crap email abcdef@ abcd. com, phone: 6657789887, IP: 255. 255. 255. 255, 1 Microsoft Way, Redmond, WA 98052. \r\nThese are all UK phone numbers, the last two being Microsoft UK support numbers: +44 870 608 4000 or 0344 800 2400 or 0800 820 3300. \r\nAlso, 544- 56- 7788 looks like a social security number ( SSN) .",
"Misrepresentation":null,
"PII":{  
  "Email":[  
    {  
      "Detected":"abcdef@abcd.com",
      "SubType":"Regular",
      "Text":"abcdef@abcd.com",
      "Index":32
    }
  ],
  "IPA":[  
    {  
      "SubType":"IPV4",
      "Text":"255.255.255.255",
      "Index":72
    }
  ],
  "Phone":[  
    {  
      "CountryCode":"US",
      "Text":"6657789887",
      "Index":56
    },
    {  
      "CountryCode":"US",
      "Text":"870 608 4000",
      "Index":211
    },
    {  
      "CountryCode":"UK",
      "Text":"+44 870 608 4000",
      "Index":207
    },
    {  
      "CountryCode":"UK",
      "Text":"0344 800 2400",
      "Index":227
    },
    {  
      "CountryCode":"UK",
      "Text":"0800 820 3300",
      "Index":244
    }
  ],
  "Address":[  
    {  
      "Text":"1 Microsoft Way, Redmond, WA 98052",
      "Index":89
    }
  ],
  "SSN":[  
    {  
      "Text":"999999999",
      "Index":56
    },
    {  
      "Text":"999-99-9999",
      "Index":266
    }
  ]
},
"Classification":{  
  "ReviewRecommended":true,
  "Category1":{  
    "Score":1.5113095059859916E-06
  },
  "Category2":{  
    "Score":0.12747249007225037
  },
  "Category3":{  
    "Score":0.98799997568130493
  }
},
"Language":"eng",
"Terms":[  
  {  
    "Index":21,
    "OriginalIndex":21,
    "ListId":0,
    "Term":"crap"
  }
],
"Status":{  
  "Code":3000,
  "Description":"OK",
  "Exception":null
},
"TrackingId":"2eaa012f-1604-4e36-a8d7-cc34b14ebcb4"
}

有关 JSON 响应中各部分的详细说明,请参阅文本审查概念指南。For a detailed explanation of all sections in the JSON response, refer to the Text moderation conceptual guide.

后续步骤Next steps

在代码中使用 REST API,或者从文本审查 .NET 快速入门开始,与你的应用程序集成。Use the REST API in your code or start with the Text moderation .NET quickstart to integrate with your application.