Types for Google Cloud Language v2 API¶
- class google.cloud.language_v2.types.AnalyzeEntitiesRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The entity analysis request message.
- document¶
Required. Input document.
- encoding_type¶
The encoding type used by the API to calculate offsets.
- class google.cloud.language_v2.types.AnalyzeEntitiesResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The entity analysis response message.
- entities¶
The recognized entities in the input document.
- Type
MutableSequence[google.cloud.language_v2.types.Entity]
- 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 [Document.language][] field for more details.
- Type
- class google.cloud.language_v2.types.AnalyzeSentimentRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The sentiment analysis request message.
- document¶
Required. Input document.
- encoding_type¶
The encoding type used by the API to calculate sentence offsets.
- class google.cloud.language_v2.types.AnalyzeSentimentResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The sentiment analysis response message.
- 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 [Document.language][] field for more details.
- Type
- sentences¶
The sentiment for all the sentences in the document.
- Type
MutableSequence[google.cloud.language_v2.types.Sentence]
- class google.cloud.language_v2.types.AnnotateTextRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The request message for the text annotation API, which can perform multiple analysis types in one call.
- document¶
Required. Input document.
- features¶
Required. The enabled features.
- encoding_type¶
The encoding type used by the API to calculate offsets.
- class Features(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
All available features. Setting each one to true will enable that specific analysis for the input.
- class google.cloud.language_v2.types.AnnotateTextResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The text annotations response message.
- sentences¶
Sentences in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
- Type
MutableSequence[google.cloud.language_v2.types.Sentence]
- entities¶
Entities, along with their semantic information, in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entities] or [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment].
- Type
MutableSequence[google.cloud.language_v2.types.Entity]
- document_sentiment¶
The overall sentiment for the document. Populated if the user enables [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
- 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 [Document.language][] field for more details.
- Type
- categories¶
Categories identified in the input document.
- Type
MutableSequence[google.cloud.language_v2.types.ClassificationCategory]
- moderation_categories¶
Harmful and sensitive categories identified in the input document.
- Type
MutableSequence[google.cloud.language_v2.types.ClassificationCategory]
- class google.cloud.language_v2.types.ClassificationCategory(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Represents a category returned from the text classifier.
- confidence¶
The classifier’s confidence of the category. Number represents how certain the classifier is that this category represents the given text.
- Type
- class google.cloud.language_v2.types.ClassifyTextRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The document classification request message.
- document¶
Required. Input document.
- class google.cloud.language_v2.types.ClassifyTextResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The document classification response message.
- categories¶
Categories representing the input document.
- Type
MutableSequence[google.cloud.language_v2.types.ClassificationCategory]
- 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 [Document.language][] field for more details.
- Type
- class google.cloud.language_v2.types.Document(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Represents the input to API methods.
This message has oneof fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.
- type_¶
Required. If the type is not set or is
TYPE_UNSPECIFIED
, returns anINVALID_ARGUMENT
error.
- content¶
The content of the input in string format. Cloud audit logging exempt since it is based on user data.
This field is a member of oneof
source
.- Type
- 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.
This field is a member of oneof
source
.- Type
- 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. Language Support lists currently supported languages for each API method. If the language (either specified by the caller or automatically detected) is not supported by the called API method, an
INVALID_ARGUMENT
error is returned.- Type
- class Type(value)[source]¶
Bases:
proto.enums.Enum
The document types enum.
- Values:
- TYPE_UNSPECIFIED (0):
The content type is not specified.
- PLAIN_TEXT (1):
Plain text
- HTML (2):
HTML
- class google.cloud.language_v2.types.EncodingType(value)[source]¶
Bases:
proto.enums.Enum
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.- Values:
- NONE (0):
If
EncodingType
is not specified, encoding-dependent information (such asbegin_offset
) will be set at-1
.- UTF8 (1):
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 (2):
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 (3):
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.
- class google.cloud.language_v2.types.Entity(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
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.
- 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.
- Type
MutableSequence[google.cloud.language_v2.types.EntityMention]
- sentiment¶
For calls to [AnalyzeEntitySentiment][] or if [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to true, this field will contain the aggregate sentiment expressed for this entity in the provided document.
- class MetadataEntry(mapping=None, *, ignore_unknown_fields=False, **kwargs)¶
Bases:
proto.message.Message
- class Type(value)[source]¶
Bases:
proto.enums.Enum
The type of the entity. The table below lists the associated fields for entities that have different metadata.
- Values:
- UNKNOWN (0):
Unknown
- PERSON (1):
Person
- LOCATION (2):
Location
- ORGANIZATION (3):
Organization
- EVENT (4):
Event
- WORK_OF_ART (5):
Artwork
- CONSUMER_GOOD (6):
Consumer product
- OTHER (7):
Other types of entities
- PHONE_NUMBER (9):
Phone number
The metadata lists the phone number, formatted according to local convention, plus whichever additional elements appear in the text:
number
- the actual number, broken down into sections as per local conventionnational_prefix
- country code, if detectedarea_code
- region or area code, if detectedextension
- phone extension (to be dialed after connection), if detected
- ADDRESS (10):
Address
The metadata identifies the street number and locality plus whichever additional elements appear in the text:
street_number
- street numberlocality
- city or townstreet_name
- street/route name, if detectedpostal_code
- postal code, if detectedcountry
- country, if detectedbroad_region
- administrative area, such as the state, if detectednarrow_region
- smaller administrative area, such as county, if detectedsublocality
- used in Asian addresses to demark a district within a city, if detected
- DATE (11):
Date
The metadata identifies the components of the date:
year
- four digit year, if detectedmonth
- two digit month number, if detectedday
- two digit day number, if detected
- NUMBER (12):
Number
The metadata is the number itself.
- PRICE (13):
Price
The metadata identifies the
value
andcurrency
.
- class google.cloud.language_v2.types.EntityMention(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
- text¶
The mention text.
- type_¶
The type of the entity mention.
- sentiment¶
For calls to [AnalyzeEntitySentiment][] or if [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to true, this field will contain the sentiment expressed for this mention of the entity in the provided document.
- 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
- class Type(value)[source]¶
Bases:
proto.enums.Enum
The supported types of mentions.
- Values:
- TYPE_UNKNOWN (0):
Unknown
- PROPER (1):
Proper name
- COMMON (2):
Common noun (or noun compound)
- class google.cloud.language_v2.types.ModerateTextRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The document moderation request message.
- document¶
Required. Input document.
- model_version¶
Optional. The model version to use for ModerateText.
- class ModelVersion(value)[source]¶
Bases:
proto.enums.Enum
The model version to use for ModerateText.
- Values:
- MODEL_VERSION_UNSPECIFIED (0):
The default model version.
- MODEL_VERSION_1 (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 (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.
- class google.cloud.language_v2.types.ModerateTextResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The document moderation response message.
- moderation_categories¶
Harmful and sensitive categories representing the input document.
- Type
MutableSequence[google.cloud.language_v2.types.ClassificationCategory]
- 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 [Document.language][] field for more details.
- Type
- class google.cloud.language_v2.types.Sentence(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Represents a sentence in the input document.
- text¶
The sentence text.
- sentiment¶
For calls to [AnalyzeSentiment][] or if [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment] is set to true, this field will contain the sentiment for the sentence.
- class google.cloud.language_v2.types.Sentiment(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Represents the feeling associated with the entire text or entities in the text.
- magnitude¶
A non-negative number in the [0, +inf) range, which represents the absolute magnitude of sentiment regardless of score (positive or negative).
- Type
- class google.cloud.language_v2.types.TextSpan(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Represents a text span in the input document.