Analyzing text with Google Cloud Natural Language
In this recipe, we will use the Google Cloud interface to evaluate text. This is similar to the earlier Analyzing images with Google Cloud Vision AI recipe but applied to text instead. We will be able to detect the language of a piece of text, as well as its general sentiment (how positive or negative it is). We will also translate all non-English text into English.
Getting ready
We need to enable the Google Cloud Natural Language API and create credentials to work with it. Most of the process is similar to the process described earlier in the chapter to enable the Vision API in a Google Cloud project, so we'll use the same project described in the earlier Analyzing images with Google Cloud Vision AI recipe.
Log into your account to go to the API dashboard at https://console.cloud.google.com/apis. Make sure you're using the same project as before, or the credentials.json
file won't work: