pythongoogle-natural-language

Vietnamese Sentiment Analysis With Google


I founded the Vietnamese which is supported in sentiment analysis. When I try the tutorial they mentioned but with an Vietnamese sentence, it just detected Vietnam language but it not show 'sentence' and 'score'.

My code:

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()

Then, I show the response on console:

{u'documentSentiment': {u'magnitude': 0, u'score': 0}, u'language': u'vi', u'sentences': []}}

Could anyone tell me why Google was not score my phrase? Thanks.


Solution

  • You are correct, Google's NLP supports Vietnamese for sentiment analysis as listed in their supported languages docs.

    I tested out their NLP API demo and tried plugging in test sentences from each of their supported languages and they all worked except for Vietnamese. My guess is that it isn't an issue with your sentence, but rather a bug on Google's part. Good find! You can report the issue to GCP here.