【发布时间】:2026-02-20 21:25:01
【问题描述】:
我创立了情绪分析支持的越南语。 当我尝试他们提到的使用越南语句子的教程时,它只检测到越南语,但没有显示“句子”和“分数”。
我的代码:
credentials = ServiceAccountCredentials.from_json_keyfile_name(settings.GOOGLE['nlp_client_secrets'],scopes=settings.GOOGLE['nlp_scope'])
http = Http()
http = credentials.authorize(http)
service = discovery.build("language", "v1", http=http, discoveryServiceUrl=DISCOVERY_URL)
service_request = service.documents().analyzeSentiment(
body={
'document': {
'type': 'PLAIN_TEXT',
'content': 'món ăn này rất tệ.'
},
'encoding_type': 'UTF8'
})
response = service_request.execute()
然后,我在控制台上显示响应:
{u'documentSentiment': {u'magnitude': 0, u'score': 0}, u'language': u'vi', u'sentences': []}}
谁能告诉我为什么 Google 没有为我的短语评分? 谢谢。
【问题讨论】:
标签: python google-natural-language