Service Client: Google::Cloud::Language::V2::LanguageService::LanguageServiceClient
Client stub representing the remote LanguageService gRPC service. Delegates call dispatching to Google::gRPC::Client.
target
The endpoint target address. Defaults to language.googleapis.com:443.
credentials
The authentication credentials provider. Defaults to application default credentials via Google::Auth.
NAME
Google::Cloud::Language::V2::LanguageService - Compiled Protocol Buffers messages for google/cloud/language/v2/language_service.proto
SYNOPSIS
use Google::Cloud::Language::V2::LanguageService;
my $msg = Google::Cloud::Language::V2::LanguageService::Document->new({
type => $type,
content => $content,
gcs_content_uri => $gcs_content_uri,
language_code => $language_code,
});
# Read or update a field
my $val = $msg->type();
# Binary wire-format roundtrip
my $bytes = $msg->serialize();
my $decoded = Google::Cloud::Language::V2::LanguageService::Document->parse($bytes);
# Canonical ProtoJSON
my $json = $msg->to_json();
DESCRIPTION
Auto-generated Protobuf message classes compiled from google/cloud/language/v2/language_service.proto. All message classes inherit from Protobuf::Message and support new(), serialize(), parse(), to_json(), from_json(), to_text(), and to_perl().
MESSAGES
Google::Cloud::Language::V2::LanguageService::Document
Represents the input to API methods.
Inherits from Protobuf::Message.
Accessors
$msg->type()/$msg->type($value)Type:
Enum(Google::Cloud::Language::V2::Document::Type)Required. If the type is not set or is `TYPE_UNSPECIFIED`, returns an `INVALID_ARGUMENT` error.
$msg->content()/$msg->content($value)Type:
StringThe content of the input in string format. Cloud audit logging exempt since it is based on user data.
$msg->gcs_content_uri()/$msg->gcs_content_uri($value)Type:
StringThe 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.
$msg->language_code()/$msg->language_code($value)Type:
StringOptional. The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are accepted.<br> [Language Support](https://cloud.google.com/natural-language/docs/languages) 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.
Enum: Document::Type
TYPE_UNSPECIFIED=>0PLAIN_TEXT=>1HTML=>2
Google::Cloud::Language::V2::LanguageService::Sentence
Represents a sentence in the input document.
Inherits from Protobuf::Message.
Accessors
$msg->text()/$msg->text($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::TextSpan)The sentence text.
$msg->sentiment()/$msg->sentiment($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::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.
Google::Cloud::Language::V2::LanguageService::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.
Inherits from Protobuf::Message.
Accessors
$msg->name()/$msg->name($value)Type:
StringThe representative name for the entity.
$msg->type()/$msg->type($value)Type:
Enum(Google::Cloud::Language::V2::Entity::Type)The entity type.
$msg->metadata()/$msg->metadata($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Entity::MetadataEntry)Metadata associated with the entity.
For the metadata associated with other entity types, see the Type table below.
$msg->mentions()/$msg->mentions($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::EntityMention)The mentions of this entity in the input document. The API currently supports proper noun mentions.
$msg->sentiment()/$msg->sentiment($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::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.
Enum: Entity::Type
UNKNOWN=>0PERSON=>1LOCATION=>2ORGANIZATION=>3EVENT=>4WORK_OF_ART=>5CONSUMER_GOOD=>6OTHER=>7PHONE_NUMBER=>9ADDRESS=>10DATE=>11NUMBER=>12PRICE=>13
Google::Cloud::Language::V2::LanguageService::Sentiment
Represents the feeling associated with the entire text or entities in the text.
Inherits from Protobuf::Message.
Accessors
$msg->magnitude()/$msg->magnitude($value)Type:
FloatA non-negative number in the [0, +inf) range, which represents the absolute magnitude of sentiment regardless of score (positive or negative).
$msg->score()/$msg->score($value)Type:
FloatSentiment score between -1.0 (negative sentiment) and 1.0 (positive sentiment).
Google::Cloud::Language::V2::LanguageService::EntityMention
Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
Inherits from Protobuf::Message.
Accessors
$msg->text()/$msg->text($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::TextSpan)The mention text.
$msg->type()/$msg->type($value)Type:
Enum(Google::Cloud::Language::V2::EntityMention::Type)The type of the entity mention.
$msg->sentiment()/$msg->sentiment($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::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.
$msg->probability()/$msg->probability($value)Type:
FloatProbability 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.
Enum: EntityMention::Type
TYPE_UNKNOWN=>0PROPER=>1COMMON=>2
Google::Cloud::Language::V2::LanguageService::TextSpan
Represents a text span in the input document.
Inherits from Protobuf::Message.
Accessors
$msg->content()/$msg->content($value)Type:
StringThe content of the text span, which is a substring of the document.
$msg->begin_offset()/$msg->begin_offset($value)Type:
Int32The API calculates the beginning offset of the content in the original document according to the [EncodingType][google.cloud.language.v2.EncodingType] specified in the API request.
Google::Cloud::Language::V2::LanguageService::ClassificationCategory
Represents a category returned from the text classifier.
Inherits from Protobuf::Message.
Accessors
$msg->name()/$msg->name($value)Type:
StringThe name of the category representing the document.
$msg->confidence()/$msg->confidence($value)Type:
FloatThe classifier's confidence of the category. Number represents how certain the classifier is that this category represents the given text.
$msg->severity()/$msg->severity($value)Type:
FloatOptional. 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.
Google::Cloud::Language::V2::LanguageService::AnalyzeSentimentRequest
The sentiment analysis request message.
Inherits from Protobuf::Message.
Accessors
$msg->document()/$msg->document($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Document)Required. Input document.
$msg->encoding_type()/$msg->encoding_type($value)Type:
Enum(Google::Cloud::Language::V2::EncodingType)The encoding type used by the API to calculate sentence offsets.
Google::Cloud::Language::V2::LanguageService::AnalyzeSentimentResponse
The sentiment analysis response message.
Inherits from Protobuf::Message.
Accessors
$msg->document_sentiment()/$msg->document_sentiment($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Sentiment)The overall sentiment of the input document.
$msg->language_code()/$msg->language_code($value)Type:
StringThe 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.
$msg->sentences()/$msg->sentences($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Sentence)The sentiment for all the sentences in the document.
$msg->language_supported()/$msg->language_supported($value)Type:
BoolWhether 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.
Google::Cloud::Language::V2::LanguageService::AnalyzeEntitiesRequest
The entity analysis request message.
Inherits from Protobuf::Message.
Accessors
$msg->document()/$msg->document($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Document)Required. Input document.
$msg->encoding_type()/$msg->encoding_type($value)Type:
Enum(Google::Cloud::Language::V2::EncodingType)The encoding type used by the API to calculate offsets.
Google::Cloud::Language::V2::LanguageService::AnalyzeEntitiesResponse
The entity analysis response message.
Inherits from Protobuf::Message.
Accessors
$msg->entities()/$msg->entities($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Entity)The recognized entities in the input document.
$msg->language_code()/$msg->language_code($value)Type:
StringThe 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.
$msg->language_supported()/$msg->language_supported($value)Type:
BoolWhether 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.
Google::Cloud::Language::V2::LanguageService::ClassifyTextRequest
The document classification request message.
Inherits from Protobuf::Message.
Accessors
$msg->document()/$msg->document($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Document)Required. Input document.
Google::Cloud::Language::V2::LanguageService::ClassifyTextResponse
The document classification response message.
Inherits from Protobuf::Message.
Accessors
$msg->categories()/$msg->categories($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::ClassificationCategory)Categories representing the input document.
$msg->language_code()/$msg->language_code($value)Type:
StringThe 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.
$msg->language_supported()/$msg->language_supported($value)Type:
BoolWhether 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.
Google::Cloud::Language::V2::LanguageService::ModerateTextRequest
The document moderation request message.
Inherits from Protobuf::Message.
Accessors
$msg->document()/$msg->document($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Document)Required. Input document.
$msg->model_version()/$msg->model_version($value)Type:
Enum(Google::Cloud::Language::V2::ModerateTextRequest::ModelVersion)Optional. The model version to use for ModerateText.
Enum: ModerateTextRequest::ModelVersion
MODEL_VERSION_UNSPECIFIED=>0MODEL_VERSION_1=>1MODEL_VERSION_2=>2
Google::Cloud::Language::V2::LanguageService::ModerateTextResponse
The document moderation response message.
Inherits from Protobuf::Message.
Accessors
$msg->moderation_categories()/$msg->moderation_categories($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::ClassificationCategory)Harmful and sensitive categories representing the input document.
$msg->language_code()/$msg->language_code($value)Type:
StringThe 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.
$msg->language_supported()/$msg->language_supported($value)Type:
BoolWhether 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.
Google::Cloud::Language::V2::LanguageService::AnnotateTextRequest
The request message for the text annotation API, which can perform multiple analysis types in one call.
Inherits from Protobuf::Message.
Accessors
$msg->document()/$msg->document($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Document)Required. Input document.
$msg->features()/$msg->features($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::AnnotateTextRequest::Features)Required. The enabled features.
$msg->encoding_type()/$msg->encoding_type($value)Type:
Enum(Google::Cloud::Language::V2::EncodingType)The encoding type used by the API to calculate offsets.
Google::Cloud::Language::V2::LanguageService::AnnotateTextResponse
The text annotations response message.
Inherits from Protobuf::Message.
Accessors
$msg->sentences()/$msg->sentences($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Sentence)Sentences in the input document. Populated if the user enables [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
$msg->entities()/$msg->entities($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::Entity)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].
$msg->document_sentiment()/$msg->document_sentiment($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::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].
$msg->language_code()/$msg->language_code($value)Type:
StringThe 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.
$msg->categories()/$msg->categories($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::ClassificationCategory)Categories identified in the input document.
$msg->moderation_categories()/$msg->moderation_categories($value)Type:
Message(Google::Cloud::Language::V2::LanguageService::ClassificationCategory)Harmful and sensitive categories identified in the input document.
$msg->language_supported()/$msg->language_supported($value)Type:
BoolWhether 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.
SEE ALSO
Protobuf, Protobuf::Message, Google::Cloud::Language::V2::LanguageService::Types, https://protobuf.dev/
LICENSE AND COPYRIGHT
Copyright (C) 2026 Google LLC
This program is released under the Apache 2.0 license.