使用翻译文本 API 添加不雅内容筛选Add profanity filtering with the Translator Text API

通常,Translator 服务在翻译中会保留源中存在的不雅内容。Normally the Translator service retains profanity that is present in the source in the translation. 不雅程度和使词语不雅的语境在不同的文化之间有所不同。The degree of profanity and the context that makes words profane differ between cultures. 因此,在目标语言中的不雅程度可能会被放大或降低。As a result, the degree of profanity in the target language may be amplified or reduced.

如果希望避免在翻译中看到不雅内容(即使源文本中存在不雅内容),可以使用 Translate() 方法中提供的不雅内容筛选选项。If you want to avoid seeing profanity in the translation, even if profanity is present in the source text, use the profanity filtering option available in the Translate() method. 使用该选项可以选择是要看到不雅内容被删除、标有相应标记还是不被执行任何操作。This option allows you to choose whether you want to see profanity deleted, marked with appropriate tags, or take no action taken.

Translate() 方法采用“options”参数,该参数包含新元素“ProfanityAction”。The Translate() method takes the “options” parameter, which contains the new element “ProfanityAction”. 可接受的 ProfanityAction 值为“NoAction”、“Marked”和“Deleted”。The accepted values of ProfanityAction are “NoAction”, “Marked” and “Deleted.”

可接受的 ProfanityAction 值和示例Accepted values of ProfanityAction and examples

ProfanityAction 值ProfanityAction value 操作Action 示例:源 - 日语Example: Source - Japanese 示例:目标 - 英语Example: Target - English
NoActionNoAction 默认。Default. 与不设置此选项等效。Same as not setting the option. 不雅内容从源传递到目标。Profanity passes from source to target. 彼は変態です。彼は変態です。 He is a jerk.He is a jerk.
MarkedMarked 将不雅词语括在 XML 标记 <profanity> ... </profanity> 内。Profane words are surrounded by XML tags <profanity> ... </profanity>. 彼は変態です。彼は変態です。 He is a <profanity>jerk</profanity>.He is a <profanity>jerk</profanity>.
DeletedDeleted 将不雅词语从输出中删除且不替换。Profane words are removed from the output without replacement. 彼は。彼は。 他是一个。He is a.

后续步骤Next steps