Index
LanguageService
(interface)AnalyzeEntitiesRequest
(message)AnalyzeEntitiesResponse
(message)AnalyzeSentimentRequest
(message)AnalyzeSentimentResponse
(message)AnnotateTextRequest
(message)AnnotateTextRequest.Features
(message)AnnotateTextResponse
(message)ClassificationCategory
(message)ClassifyTextRequest
(message)ClassifyTextResponse
(message)Document
(message)Document.Type
(enum)EncodingType
(enum)Entity
(message)Entity.Type
(enum)EntityMention
(message)EntityMention.Type
(enum)ModerateTextRequest
(message)ModerateTextRequest.ModelVersion
(enum)ModerateTextResponse
(message)Sentence
(message)Sentiment
(message)TextSpan
(message)
LanguageService
Provides text analysis operations such as sentiment analysis and entity recognition.
AnalyzeEntities |
---|
Finds named entities (currently proper names and common nouns) in the text along with entity types, probability, mentions for each entity, and other properties.
|
AnalyzeSentiment |
---|
Analyzes the sentiment of the provided text.
|
AnnotateText |
---|
A convenience method that provides all features in one call.
|
ClassifyText |
---|
Classifies a document into categories.
|
ModerateText |
---|
Moderates a document for harmful and sensitive categories.
|
AnalyzeEntitiesRequest
The entity analysis request message.
Fields | |
---|---|
document |
Required. Input document. |
encoding_type |
The encoding type used by the API to calculate offsets. |
AnalyzeEntitiesResponse
The entity analysis response message.
Fields | |
---|---|
entities[] |
The recognized entities in the input document. |
language_code |
The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See |
language_supported |
Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. |
AnalyzeSentimentRequest
The sentiment analysis request message.
Fields | |
---|---|
document |
Required. Input document. |
encoding_type |
The encoding type used by the API to calculate sentence offsets. |
AnalyzeSentimentResponse
The sentiment analysis response message.
Fields | |
---|---|
document_sentiment |
The overall sentiment of the input document. |
language_code |
The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See |
sentences[] |
The sentiment for all the sentences in the document. |
language_supported |
Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. |
AnnotateTextRequest
The request message for the text annotation API, which can perform multiple analysis types in one call.
Fields | |
---|---|
document |
Required. Input document. |
features |
Required. The enabled features. |
encoding_type |
The encoding type used by the API to calculate offsets. |
Features
All available features. Setting each one to true will enable that specific analysis for the input.
Fields | |
---|---|
extract_entities |
Optional. Extract entities. |
extract_document_sentiment |
Optional. Extract document-level sentiment. |
classify_text |
Optional. Classify the full document into categories. |
moderate_text |
Optional. Moderate the document for harmful and sensitive categories. |
AnnotateTextResponse
The text annotations response message.
Fields | |
---|---|
sentences[] |
Sentences in the input document. Populated if the user enables |
entities[] |
Entities, along with their semantic information, in the input document. Populated if the user enables |
document_sentiment |
The overall sentiment for the document. Populated if the user enables |
language_code |
The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See |
categories[] |
Categories identified in the input document. |
moderation_categories[] |
Harmful and sensitive categories identified in the input document. |
language_supported |
Whether the language is officially supported by all requested features. The API may still return a response when the language is not supported, but it is on a best effort basis. |
ClassificationCategory
Represents a category returned from the text classifier.
Fields | |
---|---|
name |
The name of the category representing the document. |
confidence |
The classifier's confidence of the category. Number represents how certain the classifier is that this category represents the given text. |
severity |
Optional. The classifier's severity of the category. This is only present when the ModerateTextRequest.ModelVersion is set to MODEL_VERSION_2, and the corresponding category has a severity score. |
ClassifyTextRequest
The document classification request message.
Fields | |
---|---|
document |
Required. Input document. |
ClassifyTextResponse
The document classification response message.
Fields | |
---|---|
categories[] |
Categories representing the input document. |
language_code |
The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See |
language_supported |
Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. |
Document
Represents the input to API methods.
Fields | |
---|---|
type |
Required. If the type is not set or is |
language_code |
Optional. The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are accepted. |
Union field source . The source of the document: a string containing the content or a Google Cloud Storage URI. source can be only one of the following: |
|
content |
The content of the input in string format. Cloud audit logging exempt since it is based on user data. |
gcs_content_uri |
The Google Cloud Storage URI where the file content is located. This URI must be of the form: gs://bucket_name/object_name. For more details, see https://cloud.google.com/storage/docs/reference-uris. NOTE: Cloud Storage object versioning is not supported. |
Type
The document types enum.
Enums | |
---|---|
TYPE_UNSPECIFIED |
The content type is not specified. |
PLAIN_TEXT |
Plain text |
HTML |
HTML |
EncodingType
Represents the text encoding that the caller uses to process the output. Providing an EncodingType
is recommended because the API provides the beginning offsets for various outputs, such as tokens and mentions, and languages that natively use different text encodings may access offsets differently.
Enums | |
---|---|
NONE |
If EncodingType is not specified, encoding-dependent information (such as begin_offset ) will be set at -1 . |
UTF8 |
Encoding-dependent information (such as begin_offset ) is calculated based on the UTF-8 encoding of the input. C++ and Go are examples of languages that use this encoding natively. |
UTF16 |
Encoding-dependent information (such as begin_offset ) is calculated based on the UTF-16 encoding of the input. Java and JavaScript are examples of languages that use this encoding natively. |
UTF32 |
Encoding-dependent information (such as begin_offset ) is calculated based on the UTF-32 encoding of the input. Python is an example of a language that uses this encoding natively. |
Entity
Represents a phrase in the text that is a known entity, such as a person, an organization, or location. The API associates information, such as probability and mentions, with entities.
Fields | |
---|---|
name |
The representative name for the entity. |
type |
The entity type. |
metadata |
Metadata associated with the entity. For the metadata associated with other entity types, see the Type table below. |
mentions[] |
The mentions of this entity in the input document. The API currently supports proper noun mentions. |
sentiment |
For calls to [AnalyzeEntitySentiment][] or if |
Type
The type of the entity. The table below lists the associated fields for entities that have different metadata.
Enums | |
---|---|
UNKNOWN |
Unknown |
PERSON |
Person |
LOCATION |
Location |
ORGANIZATION |
Organization |
EVENT |
Event |
WORK_OF_ART |
Artwork |
CONSUMER_GOOD |
Consumer product |
OTHER |
Other types of entities |
PHONE_NUMBER |
Phone number The metadata lists the phone number, formatted according to local convention, plus whichever additional elements appear in the text:
|
ADDRESS |
Address The metadata identifies the street number and locality plus whichever additional elements appear in the text:
|
DATE |
Date The metadata identifies the components of the date:
|
NUMBER |
Number The metadata is the number itself. |
PRICE |
Price The metadata identifies the |
EntityMention
Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
Fields | |
---|---|
text |
The mention text. |
type |
The type of the entity mention. |
sentiment |
For calls to [AnalyzeEntitySentiment][] or if |
probability |
Probability score associated with the entity. The score shows the probability of the entity mention being the entity type. The score is in (0, 1] range. |
Type
The supported types of mentions.
Enums | |
---|---|
TYPE_UNKNOWN |
Unknown |
PROPER |
Proper name |
COMMON |
Common noun (or noun compound) |
ModerateTextRequest
The document moderation request message.
Fields | |
---|---|
document |
Required. Input document. |
model_version |
Optional. The model version to use for ModerateText. |
ModelVersion
The model version to use for ModerateText.
Enums | |
---|---|
MODEL_VERSION_UNSPECIFIED |
The default model version. |
MODEL_VERSION_1 |
Use the v1 model, this model is used by default when not provided. The v1 model only returns probability (confidence) score for each category. |
MODEL_VERSION_2 |
Use the v2 model. The v2 model only returns probability (confidence) score for each category, and returns severity score for a subset of the categories. |
ModerateTextResponse
The document moderation response message.
Fields | |
---|---|
moderation_categories[] |
Harmful and sensitive categories representing the input document. |
language_code |
The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See |
language_supported |
Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. |
Sentence
Represents a sentence in the input document.
Fields | |
---|---|
text |
The sentence text. |
sentiment |
For calls to [AnalyzeSentiment][] or if |
Sentiment
Represents the feeling associated with the entire text or entities in the text.
Fields | |
---|---|
magnitude |
A non-negative number in the [0, +inf) range, which represents the absolute magnitude of sentiment regardless of score (positive or negative). |
score |
Sentiment score between -1.0 (negative sentiment) and 1.0 (positive sentiment). |
TextSpan
Represents a text span in the input document.
Fields | |
---|---|
content |
The content of the text span, which is a substring of the document. |
begin_offset |
The API calculates the beginning offset of the content in the original document according to the |