Azure AI services - Content safety - Text Analysis with Azure AI Content Safety:
#pip install azure-ai-contentsafety
  
import
os
from azure.ai.contentsafety import ContentSafetyClient
from azure.core.credentials import AzureKeyCredential
from azure.core.exceptions import HttpResponseError
from azure.ai.contentsafety.models import AnalyzeTextOptions, TextCategory
 
 def
analyze_text():
key = "6IblsP7u6dukqD3iQCxQcaOWDADIJQQJ99BAACYeBjFXJ3w3AAAHACOGqVgn"; #"CONTENT_SAFETY_KEY"
 
     # Create an Azure AI Content Safety client
 
     # Contruct request
 
     # Analyze text
except HttpResponseError as e:
if e.error:
print(f"Error message: {e.error.message}")
raise
print(e)
raise
 
     hate_result = next(item for item in response.categories_analysis if item.category == TextCategory.HATE)
self_harm_result = next(item for item in response.categories_analysis if item.category == TextCategory.SELF_HARM)
sexual_result = next(item for item in response.categories_analysis if item.category == TextCategory.SEXUAL)
violence_result = next(item for item in response.categories_analysis if item.category == TextCategory.VIOLENCE)
 
         if
hate_result:
if self_harm_result:
if sexual_result:
if violence_result:
 
 if __name__ == "__main__":
 
 OutPut:
from azure.ai.contentsafety import ContentSafetyClient
from azure.core.credentials import AzureKeyCredential
from azure.core.exceptions import HttpResponseError
from azure.ai.contentsafety.models import AnalyzeTextOptions, TextCategory
key = "6IblsP7u6dukqD3iQCxQcaOWDADIJQQJ99BAACYeBjFXJ3w3AAAHACOGqVgn"; #"CONTENT_SAFETY_KEY"
except HttpResponseError as e:
if e.error:
print(f"Error message: {e.error.message}")
raise
print(e)
raise
self_harm_result = next(item for item in response.categories_analysis if item.category == TextCategory.SELF_HARM)
sexual_result = next(item for item in response.categories_analysis if item.category == TextCategory.SEXUAL)
violence_result = next(item for item in response.categories_analysis if item.category == TextCategory.VIOLENCE)
if self_harm_result:
if sexual_result:
if violence_result:
 
 
 
 
851D305B79
ReplyDeletemmorpg oyunlar
sms onay go
mobil bozum
güvenilir takipçi satın alma
bot takipçi
08E2166876
ReplyDeletekiralık hacker
hacker arıyorum
kiralık hacker
hacker arıyorum
belek