我真的不明白如果我想将其用于法语文本是否需要设置一些特定的内容。我已阅读 Azure 文档。他们说使用“fr”代码。但我真的不知道该把它放在哪里。你有什么主意吗?
#Azure lib
from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential
azurekey = ""
azureendpoint = ""
def authenticate_client():
ta_credential = AzureKeyCredential(azurekey)
text_analytics_client = TextAnalyticsClient(
endpoint=azureendpoint,
credential=ta_credential)
return text_analytics_client
clientazure = authenticate_client()
if self.content:
documents = [self.content]
response = clientazure.analyze_sentiment(documents = documents)[0]
try:
self.emotion = "sentiment: {}".format(response.sentiment) + " detail: positive={0:.2f}; neutral={1:.2f}; negative={2:.2f} \n".format(response.confidence_scores.positive,response.confidence_scores.neutral,response.confidence_scores.negative,)
except Exception as e:
self.emotion = None
result = clientazure.recognize_entities(documents = documents)[0]
for entity in result.entities:
try:
self.topic = entity.text
except Exception as e:
self.topic = None
try:
self.category = entity.category
except Exception as e:
self.category = None
RISEBY
相关分类