Package com.google.cloud.language.v1 (2.15.0)

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.v1.AnalyzeEntitiesRequest

AnalyzeEntitiesRequest.Builder

The entity analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeEntitiesRequest

AnalyzeEntitiesResponse

The entity analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeEntitiesResponse

AnalyzeEntitiesResponse.Builder

The entity analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeEntitiesResponse

AnalyzeEntitySentimentRequest

The entity-level sentiment analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeEntitySentimentRequest

AnalyzeEntitySentimentRequest.Builder

The entity-level sentiment analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeEntitySentimentRequest

AnalyzeEntitySentimentResponse

The entity-level sentiment analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeEntitySentimentResponse

AnalyzeEntitySentimentResponse.Builder

The entity-level sentiment analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeEntitySentimentResponse

AnalyzeSentimentRequest

The sentiment analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeSentimentRequest

AnalyzeSentimentRequest.Builder

The sentiment analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeSentimentRequest

AnalyzeSentimentResponse

The sentiment analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeSentimentResponse

AnalyzeSentimentResponse.Builder

The sentiment analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeSentimentResponse

AnalyzeSyntaxRequest

The syntax analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeSyntaxRequest

AnalyzeSyntaxRequest.Builder

The syntax analysis request message.

Protobuf type google.cloud.language.v1.AnalyzeSyntaxRequest

AnalyzeSyntaxResponse

The syntax analysis response message.

Protobuf type google.cloud.language.v1.AnalyzeSyntaxResponse

AnalyzeSyntaxResponse.Builder

The syntax analysis response message.

Protobuf type google.cloud.language.v1.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.v1.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.v1.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.

Protobuf type google.cloud.language.v1.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.

Protobuf type google.cloud.language.v1.AnnotateTextRequest.Features

AnnotateTextResponse

The text annotations response message.

Protobuf type google.cloud.language.v1.AnnotateTextResponse

AnnotateTextResponse.Builder

The text annotations response message.

Protobuf type google.cloud.language.v1.AnnotateTextResponse

ClassificationCategory

Represents a category returned from the text classifier.

Protobuf type google.cloud.language.v1.ClassificationCategory

ClassificationCategory.Builder

Represents a category returned from the text classifier.

Protobuf type google.cloud.language.v1.ClassificationCategory

ClassificationModelOptions

Model options available for classification requests.

Protobuf type google.cloud.language.v1.ClassificationModelOptions

ClassificationModelOptions.Builder

Model options available for classification requests.

Protobuf type google.cloud.language.v1.ClassificationModelOptions

ClassificationModelOptions.V1Model

Options for the V1 model.

Protobuf type google.cloud.language.v1.ClassificationModelOptions.V1Model

ClassificationModelOptions.V1Model.Builder

Options for the V1 model.

Protobuf type google.cloud.language.v1.ClassificationModelOptions.V1Model

ClassificationModelOptions.V2Model

Options for the V2 model.

Protobuf type google.cloud.language.v1.ClassificationModelOptions.V2Model

ClassificationModelOptions.V2Model.Builder

Options for the V2 model.

Protobuf type google.cloud.language.v1.ClassificationModelOptions.V2Model

ClassifyTextRequest

The document classification request message.

Protobuf type google.cloud.language.v1.ClassifyTextRequest

ClassifyTextRequest.Builder

The document classification request message.

Protobuf type google.cloud.language.v1.ClassifyTextRequest

ClassifyTextResponse

The document classification response message.

Protobuf type google.cloud.language.v1.ClassifyTextResponse

ClassifyTextResponse.Builder

The document classification response message.

Protobuf type google.cloud.language.v1.ClassifyTextResponse

DependencyEdge

Represents dependency parse tree information for a token. (For more information on dependency labels, see http://www.aclweb.org/anthology/P13-2017

Protobuf type google.cloud.language.v1.DependencyEdge

DependencyEdge.Builder

Represents dependency parse tree information for a token. (For more information on dependency labels, see http://www.aclweb.org/anthology/P13-2017

Protobuf type google.cloud.language.v1.DependencyEdge

Document

Represents the input to API methods.

Protobuf type google.cloud.language.v1.Document

Document.Builder

Represents the input to API methods.

Protobuf type google.cloud.language.v1.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.v1.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.v1.Entity

EntityMention

Represents a mention for an entity in the text. Currently, proper noun mentions are supported.

Protobuf type google.cloud.language.v1.EntityMention

EntityMention.Builder

Represents a mention for an entity in the text. Currently, proper noun mentions are supported.

Protobuf type google.cloud.language.v1.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:

  1. 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.
  2. 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.
  3. 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

A stub to allow clients to do synchronous rpc calls to service LanguageService.

Provides text analysis operations such as sentiment analysis and entity recognition.

LanguageServiceGrpc.LanguageServiceFutureStub

A stub to allow clients to do ListenableFuture-style rpc calls to service LanguageService.

Provides text analysis operations such as sentiment analysis and entity recognition.

LanguageServiceGrpc.LanguageServiceImplBase

Base class for the server implementation of the service LanguageService.

Provides text analysis operations such as sentiment analysis and entity recognition.

LanguageServiceGrpc.LanguageServiceStub

A stub to allow clients to do asynchronous rpc calls to service LanguageService.

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. Parts of speech are as defined in http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf

Protobuf type google.cloud.language.v1.PartOfSpeech

PartOfSpeech.Builder

Represents part of speech information for a token. Parts of speech are as defined in http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf

Protobuf type google.cloud.language.v1.PartOfSpeech

Sentence

Represents a sentence in the input document.

Protobuf type google.cloud.language.v1.Sentence

Sentence.Builder

Represents a sentence in the input document.

Protobuf type google.cloud.language.v1.Sentence

Sentiment

Represents the feeling associated with the entire text or entities in the text.

Protobuf type google.cloud.language.v1.Sentiment

Sentiment.Builder

Represents the feeling associated with the entire text or entities in the text.

Protobuf type google.cloud.language.v1.Sentiment

TextSpan

Represents an output piece of text.

Protobuf type google.cloud.language.v1.TextSpan

TextSpan.Builder

Represents an output piece of text.

Protobuf type google.cloud.language.v1.TextSpan

Token

Represents the smallest syntactic building block of the text.

Protobuf type google.cloud.language.v1.Token

Token.Builder

Represents the smallest syntactic building block of the text.

Protobuf type google.cloud.language.v1.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

LanguageServiceGrpc.AsyncService

Provides text analysis operations such as sentiment analysis and entity recognition.

PartOfSpeechOrBuilder

SentenceOrBuilder

SentimentOrBuilder

TextSpanOrBuilder

TokenOrBuilder

Enums

ClassificationModelOptions.ModelTypeCase

ClassificationModelOptions.V2Model.ContentCategoriesVersion

The content categories used for classification.

Protobuf enum google.cloud.language.v1.ClassificationModelOptions.V2Model.ContentCategoriesVersion

DependencyEdge.Label

The parse label enum for the token.

Protobuf enum google.cloud.language.v1.DependencyEdge.Label

Document.SourceCase

Document.Type

The document types enum.

Protobuf enum google.cloud.language.v1.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.v1.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.v1.Entity.Type

EntityMention.Type

The supported types of mentions.

Protobuf enum google.cloud.language.v1.EntityMention.Type

PartOfSpeech.Aspect

The characteristic of a verb that expresses time flow during an event.

Protobuf enum google.cloud.language.v1.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.v1.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.v1.PartOfSpeech.Form

PartOfSpeech.Gender

Gender classes of nouns reflected in the behaviour of associated words.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Gender

PartOfSpeech.Mood

The grammatical feature of verbs, used for showing modality and attitude.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Mood

PartOfSpeech.Number

Count distinctions.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Number

PartOfSpeech.Person

The distinction between the speaker, second person, third person, etc.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Person

PartOfSpeech.Proper

This category shows if the token is part of a proper name.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Proper

PartOfSpeech.Reciprocity

Reciprocal features of a pronoun.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Reciprocity

PartOfSpeech.Tag

The part of speech tags enum.

Protobuf enum google.cloud.language.v1.PartOfSpeech.Tag

PartOfSpeech.Tense

Time reference.

Protobuf enum google.cloud.language.v1.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.v1.PartOfSpeech.Voice