- 2.56.0 (latest)
- 2.55.0
- 2.54.0
- 2.53.0
- 2.52.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.1
- 2.3.4
- 2.2.0
- 2.1.10
A client to Cloud Natural Language API
The interfaces provided are listed below, along with usage samples.
LanguageServiceClient
Service Description: Provides text analysis operations such as sentiment analysis and entity recognition.
Sample for LanguageServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
Document document = Document.newBuilder().build();
AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
}
Classes
AnalyzeEntitiesRequest
The entity analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitiesRequest
AnalyzeEntitiesRequest.Builder
The entity analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitiesRequest
AnalyzeEntitiesResponse
The entity analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitiesResponse
AnalyzeEntitiesResponse.Builder
The entity analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitiesResponse
AnalyzeEntitySentimentRequest
The entity-level sentiment analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest
AnalyzeEntitySentimentRequest.Builder
The entity-level sentiment analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest
AnalyzeEntitySentimentResponse
The entity-level sentiment analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse
AnalyzeEntitySentimentResponse.Builder
The entity-level sentiment analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse
AnalyzeSentimentRequest
The sentiment analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSentimentRequest
AnalyzeSentimentRequest.Builder
The sentiment analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSentimentRequest
AnalyzeSentimentResponse
The sentiment analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSentimentResponse
AnalyzeSentimentResponse.Builder
The sentiment analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSentimentResponse
AnalyzeSyntaxRequest
The syntax analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSyntaxRequest
AnalyzeSyntaxRequest.Builder
The syntax analysis request message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSyntaxRequest
AnalyzeSyntaxResponse
The syntax analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSyntaxResponse
AnalyzeSyntaxResponse.Builder
The syntax analysis response message.
Protobuf type google.cloud.language.v1beta2.AnalyzeSyntaxResponse
AnnotateTextRequest
The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call.
Protobuf type google.cloud.language.v1beta2.AnnotateTextRequest
AnnotateTextRequest.Builder
The request message for the text annotation API, which can perform multiple analysis types (sentiment, entities, and syntax) in one call.
Protobuf type google.cloud.language.v1beta2.AnnotateTextRequest
AnnotateTextRequest.Features
All available features for sentiment, syntax, and semantic analysis. Setting each one to true will enable that specific analysis for the input. Next ID: 11
Protobuf type google.cloud.language.v1beta2.AnnotateTextRequest.Features
AnnotateTextRequest.Features.Builder
All available features for sentiment, syntax, and semantic analysis. Setting each one to true will enable that specific analysis for the input. Next ID: 11
Protobuf type google.cloud.language.v1beta2.AnnotateTextRequest.Features
AnnotateTextResponse
The text annotations response message.
Protobuf type google.cloud.language.v1beta2.AnnotateTextResponse
AnnotateTextResponse.Builder
The text annotations response message.
Protobuf type google.cloud.language.v1beta2.AnnotateTextResponse
ClassificationCategory
Represents a category returned from the text classifier.
Protobuf type google.cloud.language.v1beta2.ClassificationCategory
ClassificationCategory.Builder
Represents a category returned from the text classifier.
Protobuf type google.cloud.language.v1beta2.ClassificationCategory
ClassificationModelOptions
Model options available for classification requests.
Protobuf type google.cloud.language.v1beta2.ClassificationModelOptions
ClassificationModelOptions.Builder
Model options available for classification requests.
Protobuf type google.cloud.language.v1beta2.ClassificationModelOptions
ClassificationModelOptions.V1Model
Options for the V1 model.
Protobuf type google.cloud.language.v1beta2.ClassificationModelOptions.V1Model
ClassificationModelOptions.V1Model.Builder
Options for the V1 model.
Protobuf type google.cloud.language.v1beta2.ClassificationModelOptions.V1Model
ClassificationModelOptions.V2Model
Options for the V2 model.
Protobuf type google.cloud.language.v1beta2.ClassificationModelOptions.V2Model
ClassificationModelOptions.V2Model.Builder
Options for the V2 model.
Protobuf type google.cloud.language.v1beta2.ClassificationModelOptions.V2Model
ClassifyTextRequest
The document classification request message.
Protobuf type google.cloud.language.v1beta2.ClassifyTextRequest
ClassifyTextRequest.Builder
The document classification request message.
Protobuf type google.cloud.language.v1beta2.ClassifyTextRequest
ClassifyTextResponse
The document classification response message.
Protobuf type google.cloud.language.v1beta2.ClassifyTextResponse
ClassifyTextResponse.Builder
The document classification response message.
Protobuf type google.cloud.language.v1beta2.ClassifyTextResponse
DependencyEdge
Represents dependency parse tree information for a token.
Protobuf type google.cloud.language.v1beta2.DependencyEdge
DependencyEdge.Builder
Represents dependency parse tree information for a token.
Protobuf type google.cloud.language.v1beta2.DependencyEdge
Document
Represents the input to API methods.
Protobuf type google.cloud.language.v1beta2.Document
Document.Builder
Represents the input to API methods.
Protobuf type google.cloud.language.v1beta2.Document
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 salience and mentions, with entities.
Protobuf type google.cloud.language.v1beta2.Entity
Entity.Builder
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 salience and mentions, with entities.
Protobuf type google.cloud.language.v1beta2.Entity
EntityMention
Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
Protobuf type google.cloud.language.v1beta2.EntityMention
EntityMention.Builder
Represents a mention for an entity in the text. Currently, proper noun mentions are supported.
Protobuf type google.cloud.language.v1beta2.EntityMention
LanguageServiceClient
Service Description: Provides text analysis operations such as sentiment analysis and entity recognition.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
Document document = Document.newBuilder().build();
AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
}
Note: close() needs to be called on the LanguageServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of LanguageServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
LanguageServiceSettings languageServiceSettings =
LanguageServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
LanguageServiceClient languageServiceClient =
LanguageServiceClient.create(languageServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
LanguageServiceSettings languageServiceSettings =
LanguageServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
LanguageServiceClient languageServiceClient =
LanguageServiceClient.create(languageServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
LanguageServiceSettings languageServiceSettings =
LanguageServiceSettings.newHttpJsonBuilder().build();
LanguageServiceClient languageServiceClient =
LanguageServiceClient.create(languageServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
LanguageServiceGrpc
Provides text analysis operations such as sentiment analysis and entity recognition.
LanguageServiceGrpc.LanguageServiceBlockingStub
Provides text analysis operations such as sentiment analysis and entity recognition.
LanguageServiceGrpc.LanguageServiceFutureStub
Provides text analysis operations such as sentiment analysis and entity recognition.
LanguageServiceGrpc.LanguageServiceImplBase
Provides text analysis operations such as sentiment analysis and entity recognition.
LanguageServiceGrpc.LanguageServiceStub
Provides text analysis operations such as sentiment analysis and entity recognition.
LanguageServiceProto
LanguageServiceSettings
Settings class to configure an instance of LanguageServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (language.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of analyzeSentiment to 30 seconds:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
LanguageServiceSettings.Builder languageServiceSettingsBuilder =
LanguageServiceSettings.newBuilder();
languageServiceSettingsBuilder
.analyzeSentimentSettings()
.setRetrySettings(
languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
LanguageServiceSettings languageServiceSettings = languageServiceSettingsBuilder.build();
LanguageServiceSettings.Builder
Builder for LanguageServiceSettings.
PartOfSpeech
Represents part of speech information for a token.
Protobuf type google.cloud.language.v1beta2.PartOfSpeech
PartOfSpeech.Builder
Represents part of speech information for a token.
Protobuf type google.cloud.language.v1beta2.PartOfSpeech
Sentence
Represents a sentence in the input document.
Protobuf type google.cloud.language.v1beta2.Sentence
Sentence.Builder
Represents a sentence in the input document.
Protobuf type google.cloud.language.v1beta2.Sentence
Sentiment
Represents the feeling associated with the entire text or entities in the text. Next ID: 6
Protobuf type google.cloud.language.v1beta2.Sentiment
Sentiment.Builder
Represents the feeling associated with the entire text or entities in the text. Next ID: 6
Protobuf type google.cloud.language.v1beta2.Sentiment
TextSpan
Represents an output piece of text.
Protobuf type google.cloud.language.v1beta2.TextSpan
TextSpan.Builder
Represents an output piece of text.
Protobuf type google.cloud.language.v1beta2.TextSpan
Token
Represents the smallest syntactic building block of the text.
Protobuf type google.cloud.language.v1beta2.Token
Token.Builder
Represents the smallest syntactic building block of the text.
Protobuf type google.cloud.language.v1beta2.Token
Interfaces
AnalyzeEntitiesRequestOrBuilder
AnalyzeEntitiesResponseOrBuilder
AnalyzeEntitySentimentRequestOrBuilder
AnalyzeEntitySentimentResponseOrBuilder
AnalyzeSentimentRequestOrBuilder
AnalyzeSentimentResponseOrBuilder
AnalyzeSyntaxRequestOrBuilder
AnalyzeSyntaxResponseOrBuilder
AnnotateTextRequest.FeaturesOrBuilder
AnnotateTextRequestOrBuilder
AnnotateTextResponseOrBuilder
ClassificationCategoryOrBuilder
ClassificationModelOptions.V1ModelOrBuilder
ClassificationModelOptions.V2ModelOrBuilder
ClassificationModelOptionsOrBuilder
ClassifyTextRequestOrBuilder
ClassifyTextResponseOrBuilder
DependencyEdgeOrBuilder
DocumentOrBuilder
EntityMentionOrBuilder
EntityOrBuilder
PartOfSpeechOrBuilder
SentenceOrBuilder
SentimentOrBuilder
TextSpanOrBuilder
TokenOrBuilder
Enums
ClassificationModelOptions.ModelTypeCase
ClassificationModelOptions.V2Model.ContentCategoriesVersion
The content categories used for classification.
Protobuf enum
google.cloud.language.v1beta2.ClassificationModelOptions.V2Model.ContentCategoriesVersion
DependencyEdge.Label
The parse label enum for the token.
Protobuf enum google.cloud.language.v1beta2.DependencyEdge.Label
Document.BoilerplateHandling
Ways of handling boilerplate detected in the document
Protobuf enum google.cloud.language.v1beta2.Document.BoilerplateHandling
Document.SourceCase
Document.Type
The document types enum.
Protobuf enum google.cloud.language.v1beta2.Document.Type
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.
Protobuf enum google.cloud.language.v1beta2.EncodingType
Entity.Type
The type of the entity. For most entity types, the associated metadata is a
Wikipedia URL (wikipedia_url
) and Knowledge Graph MID (mid
). The table
below lists the associated fields for entities that have different
metadata.
Protobuf enum google.cloud.language.v1beta2.Entity.Type
EntityMention.Type
The supported types of mentions.
Protobuf enum google.cloud.language.v1beta2.EntityMention.Type
PartOfSpeech.Aspect
The characteristic of a verb that expresses time flow during an event.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Aspect
PartOfSpeech.Case
The grammatical function performed by a noun or pronoun in a phrase, clause, or sentence. In some languages, other parts of speech, such as adjective and determiner, take case inflection in agreement with the noun.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Case
PartOfSpeech.Form
Depending on the language, Form can be categorizing different forms of verbs, adjectives, adverbs, etc. For example, categorizing inflected endings of verbs and adjectives or distinguishing between short and long forms of adjectives and participles
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Form
PartOfSpeech.Gender
Gender classes of nouns reflected in the behaviour of associated words.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Gender
PartOfSpeech.Mood
The grammatical feature of verbs, used for showing modality and attitude.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Mood
PartOfSpeech.Number
Count distinctions.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Number
PartOfSpeech.Person
The distinction between the speaker, second person, third person, etc.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Person
PartOfSpeech.Proper
This category shows if the token is part of a proper name.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Proper
PartOfSpeech.Reciprocity
Reciprocal features of a pronoun.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Reciprocity
PartOfSpeech.Tag
The part of speech tags enum.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Tag
PartOfSpeech.Tense
Time reference.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Tense
PartOfSpeech.Voice
The relationship between the action that a verb expresses and the participants identified by its arguments.
Protobuf enum google.cloud.language.v1beta2.PartOfSpeech.Voice