Google Text Analytics
(Available from version 7.2 onwards.)
Google Text Analytics Library uses Google’s Natural Language service to process input text and provide Sentiment Analysis, Entity Recognition, Entity Sentiment Analysis, Text Translation, and Content Classification functions.
Use the functions listed below to submit requests to Google Text Analytics. To use a function, you must first create an instance of the appropriate variable type to which to assign the function's response. For example, you must create an instance of a Google Entity Response variable to capture the response to a Google Entity Recognition function. For information on those variable types, see here.
Prerequisites
To use Google Text Analytics, ensure that you have all of the following:
-
An active Google Cloud account. To create an account, see here.
-
An active Internet connection on your machine. The machine on which the automation will be run will also need an active Internet connection.
-
An API key and endpoint for the Google Text Analytics service. (These must be stored in a variable of type Google client credential, see here.)
Functions
An individual example is provided for each function described in this topic.
Download the project here and unzip to the folder %AppData%/Nice_Systems/AutomationStudio/Projects\. This project includes one workflow per function.
You must first enter your credential details before you can use these examples:
-
In the Assets Panel, locate the variable GoogleClientCredential, click the Menu button, and select Edit.
-
Click API Key.
-
Enter your Google Analytics key in the Initial Value field.
-
Click End Point.
-
Enter your Google Analytics end point.
-
Click Save.
-
In the Assets Panel, locate the variable TranslationAPIKey, click the Menu button, and select Edit.
-
Enter your Google Cloud Translation key in the Initial Value field.
-
Click Save.
Requests sentiment analysis of specified text from Google Text Analytics to obtain a sentiment score from -1 (negative) to +1 (positive). See Google's documentation for more information. For a list of supported languages, see here.
Parameters
Parameter |
Input Type |
Description |
---|---|---|
Google Client Credential | Google client credential | The name of the variable of type Google Client Credential that holds your Google Text Analytics key and endpoint URL. |
Plain or HTML |
text |
The type of text provided, either Plain or HTML. If left empty, Plain is assumed. Google will correctly identify plain text even if HTML is incorrectly specified. |
Encoding Type |
text |
The encoding of the text provided. Valid values include: None, UTF8, UTF16, UTF32 If not specified, None will be assumed. |
Text for Analysis |
text |
The text for sentiment analysis. |
Returns
Sentiment analysis results in Google Sentiment Response format
Example
This example requests sentiment analysis on the following text:
I am writing about the service I received on Monday. I was extremely satisfied and would like to thank you very much for the fantastic service.
The workflow is shown below. The result is stored in the variable SentimentResponse.
The results are shown below.
Note the following:
-
Under Sentences, two elements are listed - one for each of the two sentences.
-
The Score for the first sentence is 0 as the sentence has a neutral sentiment.
-
The Score for the second sentence is 0.89 as the sentence has a very positive sentiment.
-
Under Sentiment, the Score is 0.5 as overall the text provided has a positive sentiment.
Requests entity analysis of specified text from Google Text Analytics to identify named entities present in the text.
See Google's documentation for more information. For a list of supported languages, see here.
Parameters
Parameter |
Input Type |
Description |
---|---|---|
Google Client Credential | Google client credential | The name of the variable of type Google Client Credential that holds your Google Text Analytics key and endpoint URL. |
Plain or HTML |
text |
The type of text provided, either Plain or HTML. If left empty, Plain is assumed. Google will correctly identify plain text even if HTML is incorrectly specified. |
Encoding Type |
text |
The encoding of the text provided. Valid values include: None, UTF8, UTF16, UTF32 If not specified, None will be assumed. |
Text for Analysis |
text |
The text for entity recognition. |
Returns
A list of entity recognition analysis results in Google Entity Response format
Example
This example requests entity recognition on the following text:
Paris was extremely enjoyable. Our guide, Guy de Lombard, was helpful and pleasant. Unfortunately, our hotel, Chateau Granville, was dirty and offered terrible service.
The workflow is shown below. The result is stored in the variable EntityResponse.
The results are shown below.
Note the following:
-
Six elements (entities) were identified.
-
The first element, Paris, is identified as a location.
-
The fourth element, Guy de Lombard, is identified as a person.
-
The language of the text is recognized as English.
Requests entity sentiment analysis of specified text from Google Text Analytics to identify named entities present in the text and obtain a sentiment score for each.
See Google's documentation for more information. For a list of supported languages, see here.
Parameters
Parameter |
Input Type |
Description |
---|---|---|
Google Client Credential | Google client credential | The name of the variable of type Google Client Credential that holds your Google Text Analytics key and endpoint URL. |
Plain or HTML |
text |
The type of text provided, either Plain or HTML. If left empty, Plain is assumed. Google will correctly identify plain text even if HTML is incorrectly specified. |
Encoding Type |
text |
The encoding of the text provided. Valid values include: None, UTF8, UTF16, UTF32 If not specified, None will be assumed. |
Text for Analysis |
text |
The text for entity sentiment analysis. |
Returns
A list of entity sentiment analysis results in Google Entity Response format
Example
This example requests entity sentiment analysis on the following text:
The hamburgers were delicious. The manager, Elaine, was extremely helpful. However, our waiter, Fred, was very slow and unpleasant.
The workflow is shown below. The result is stored in the variable EntitySentimentResponse.
The results are shown below.
Note the following:
-
Three entities were identified (Elaine, the hamburger, and Fred).
-
Hamburgers were mentioned once and have a sentiment score of 0.89 (very positive).
-
Fred was mentioned once and has a sentiment score of -0.6 (very negative).
Requests that specified text be classified according to Google's list of content categories.
See Google's documentation for more information. For a list of supported languages, see here.
Parameters
Parameter |
Input Type |
Description |
---|---|---|
Google Client Credential | Google client credential | The name of the variable of type Google Client Credential that holds your Google Text Analytics key and endpoint URL. |
Plain or HTML |
text |
The type of text provided, either Plain or HTML. If left empty, Plain is assumed. Google will correctly identify plain text even if HTML is incorrectly specified. |
Text for Analysis |
text |
The text for content classification. |
Returns
Entity content classification results in Google Classify Text Response format
Example
This example requests content classification on the following text:
In physics, special relativity (also known as the special theory of relativity) is the generally accepted and experimentally confirmed physical theory regarding the relationship between space and time.
Attribution: Wikipedia, Creative Commons
The workflow is shown below. The result is stored in the variable ClassifyTextResponse.
The results are shown below.
Note the following:
-
Only one content category (element) was identified.
-
The text was assigned the category Science/Physics.
-
The level of confidence in the category assignment was 1 (very high).
Requests translation of specified text by Google Translate.
See Google's documentation for more information.
For information on quotas and limitations on the usage of text translation features, see here.
Parameters
Parameter |
Input Type |
Description |
---|---|---|
API Key | text | Your API key for Google Cloud Translation. |
Plain or HTML |
text |
The type of text provided, either Plain or HTML. If left empty, Plain is assumed. Google will correctly identify plain text even if HTML is incorrectly specified. |
Source Language Code |
text |
The code of the language of the original text. For a list of supported languages and their codes, see here. |
Target Language Code |
text |
The code of the language to translate into. For a list of supported languages and their codes, see here. |
Timeout |
number |
After how many seconds the request should time out. If not specified, the default value of 30 seconds will be used. |
Text |
text |
The text to translate. |
Returns
Translated text in Text format
Example
This example requests translation of the following text from English to Spanish.
Good morning. I would like to order five kilograms of cheese.
The workflow is shown below. The result is stored in the variable TranslationResponse.
The results are shown below.