亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

azure - Python - 分析法語文本。法國參數?

azure - Python - 分析法語文本。法國參數?

鴻蒙傳說 2023-12-26 16:43:48
我真的不明白如果我想將其用于法語文本是否需要設置一些特定的內容。我已閱讀 Azure 文檔。他們說使用“fr”代碼。但我真的不知道該把它放在哪里。你有什么主意嗎?#Azure libfrom azure.ai.textanalytics import TextAnalyticsClientfrom azure.core.credentials import AzureKeyCredentialazurekey = ""azureendpoint = ""def authenticate_client():    ta_credential = AzureKeyCredential(azurekey)    text_analytics_client = TextAnalyticsClient(            endpoint=azureendpoint,             credential=ta_credential)    return text_analytics_clientclientazure = 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
查看完整描述

1 回答

?
RISEBY

TA貢獻1856條經驗 獲得超5個贊

語言代碼可以放置在每個文本文檔中,也可以放置在整個批次中。analyze_sentiment()如果您想"fr"申請所有文件,請將其傳遞到電話中:

response = clientazure.analyze_sentiment(documents = documents, language="fr")

如果只想將語言代碼應用于單個文檔,請在文檔級別傳遞語言代碼。假設self.content包含您要分析的文本,它看起來像這樣:

documents = [{"id": "1", "language": "fr", "text": self.content}]


查看完整回答
反對 回復 2023-12-26
  • 1 回答
  • 0 關注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號