@BetaApi @Generated(value="by gapic-generator-java") public class LanguageServiceClient extends Object implements BackgroundResource
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:
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.newBuilder()
.setTransportChannelProvider(
LanguageServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
LanguageServiceClient languageServiceClient =
LanguageServiceClient.create(languageServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier | Constructor and Description |
---|---|
protected |
LanguageServiceClient(LanguageServiceSettings settings)
Constructs an instance of LanguageServiceClient, using the given settings.
|
protected |
LanguageServiceClient(LanguageServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
AnalyzeEntitiesResponse |
analyzeEntities(AnalyzeEntitiesRequest request)
Finds named entities (currently proper names and common nouns) in the text along with entity
types, salience, mentions for each entity, and other properties.
|
AnalyzeEntitiesResponse |
analyzeEntities(Document document)
Finds named entities (currently proper names and common nouns) in the text along with entity
types, salience, mentions for each entity, and other properties.
|
AnalyzeEntitiesResponse |
analyzeEntities(Document document,
EncodingType encodingType)
Finds named entities (currently proper names and common nouns) in the text along with entity
types, salience, mentions for each entity, and other properties.
|
UnaryCallable<AnalyzeEntitiesRequest,AnalyzeEntitiesResponse> |
analyzeEntitiesCallable()
Finds named entities (currently proper names and common nouns) in the text along with entity
types, salience, mentions for each entity, and other properties.
|
AnalyzeEntitySentimentResponse |
analyzeEntitySentiment(AnalyzeEntitySentimentRequest request)
Finds entities, similar to
[AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
and analyzes sentiment associated with each entity and its mentions.
|
AnalyzeEntitySentimentResponse |
analyzeEntitySentiment(Document document)
Finds entities, similar to
[AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
and analyzes sentiment associated with each entity and its mentions.
|
AnalyzeEntitySentimentResponse |
analyzeEntitySentiment(Document document,
EncodingType encodingType)
Finds entities, similar to
[AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
and analyzes sentiment associated with each entity and its mentions.
|
UnaryCallable<AnalyzeEntitySentimentRequest,AnalyzeEntitySentimentResponse> |
analyzeEntitySentimentCallable()
Finds entities, similar to
[AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
and analyzes sentiment associated with each entity and its mentions.
|
AnalyzeSentimentResponse |
analyzeSentiment(AnalyzeSentimentRequest request)
Analyzes the sentiment of the provided text.
|
AnalyzeSentimentResponse |
analyzeSentiment(Document document)
Analyzes the sentiment of the provided text.
|
AnalyzeSentimentResponse |
analyzeSentiment(Document document,
EncodingType encodingType)
Analyzes the sentiment of the provided text.
|
UnaryCallable<AnalyzeSentimentRequest,AnalyzeSentimentResponse> |
analyzeSentimentCallable()
Analyzes the sentiment of the provided text.
|
AnalyzeSyntaxResponse |
analyzeSyntax(AnalyzeSyntaxRequest request)
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
part of speech tags, dependency trees, and other properties.
|
AnalyzeSyntaxResponse |
analyzeSyntax(Document document)
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
part of speech tags, dependency trees, and other properties.
|
AnalyzeSyntaxResponse |
analyzeSyntax(Document document,
EncodingType encodingType)
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
part of speech tags, dependency trees, and other properties.
|
UnaryCallable<AnalyzeSyntaxRequest,AnalyzeSyntaxResponse> |
analyzeSyntaxCallable()
Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
part of speech tags, dependency trees, and other properties.
|
AnnotateTextResponse |
annotateText(AnnotateTextRequest request)
A convenience method that provides all syntax, sentiment, entity, and classification features
in one call.
|
AnnotateTextResponse |
annotateText(Document document,
AnnotateTextRequest.Features features)
A convenience method that provides all syntax, sentiment, entity, and classification features
in one call.
|
AnnotateTextResponse |
annotateText(Document document,
AnnotateTextRequest.Features features,
EncodingType encodingType)
A convenience method that provides all syntax, sentiment, entity, and classification features
in one call.
|
UnaryCallable<AnnotateTextRequest,AnnotateTextResponse> |
annotateTextCallable()
A convenience method that provides all syntax, sentiment, entity, and classification features
in one call.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
ClassifyTextResponse |
classifyText(ClassifyTextRequest request)
Classifies a document into categories.
|
ClassifyTextResponse |
classifyText(Document document)
Classifies a document into categories.
|
UnaryCallable<ClassifyTextRequest,ClassifyTextResponse> |
classifyTextCallable()
Classifies a document into categories.
|
void |
close() |
static LanguageServiceClient |
create()
Constructs an instance of LanguageServiceClient with default settings.
|
static LanguageServiceClient |
create(LanguageServiceSettings settings)
Constructs an instance of LanguageServiceClient, using the given settings.
|
static LanguageServiceClient |
create(LanguageServiceStub stub)
Constructs an instance of LanguageServiceClient, using the given stub for making calls.
|
LanguageServiceSettings |
getSettings() |
LanguageServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
void |
shutdownNow() |
protected LanguageServiceClient(LanguageServiceSettings settings) throws IOException
IOException
protected LanguageServiceClient(LanguageServiceStub stub)
public static final LanguageServiceClient create() throws IOException
IOException
public static final LanguageServiceClient create(LanguageServiceSettings settings) throws IOException
IOException
public static final LanguageServiceClient create(LanguageServiceStub stub)
public final LanguageServiceSettings getSettings()
public LanguageServiceStub getStub()
public final AnalyzeSentimentResponse analyzeSentiment(Document document)
Sample code:
// 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);
}
document
- Required. Input document.ApiException
- if the remote call failspublic final AnalyzeSentimentResponse analyzeSentiment(Document document, EncodingType encodingType)
Sample code:
// 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();
EncodingType encodingType = EncodingType.forNumber(0);
AnalyzeSentimentResponse response =
languageServiceClient.analyzeSentiment(document, encodingType);
}
document
- Required. Input document.encodingType
- The encoding type used by the API to calculate sentence offsets for the
sentence sentiment.ApiException
- if the remote call failspublic final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest request)
Sample code:
// 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()) {
AnalyzeSentimentRequest request =
AnalyzeSentimentRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AnalyzeSentimentRequest,AnalyzeSentimentResponse> analyzeSentimentCallable()
Sample code:
// 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()) {
AnalyzeSentimentRequest request =
AnalyzeSentimentRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
ApiFuture<AnalyzeSentimentResponse> future =
languageServiceClient.analyzeSentimentCallable().futureCall(request);
// Do something.
AnalyzeSentimentResponse response = future.get();
}
public final AnalyzeEntitiesResponse analyzeEntities(Document document)
Sample code:
// 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();
AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
}
document
- Required. Input document.ApiException
- if the remote call failspublic final AnalyzeEntitiesResponse analyzeEntities(Document document, EncodingType encodingType)
Sample code:
// 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();
EncodingType encodingType = EncodingType.forNumber(0);
AnalyzeEntitiesResponse response =
languageServiceClient.analyzeEntities(document, encodingType);
}
document
- Required. Input document.encodingType
- The encoding type used by the API to calculate offsets.ApiException
- if the remote call failspublic final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest request)
Sample code:
// 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()) {
AnalyzeEntitiesRequest request =
AnalyzeEntitiesRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AnalyzeEntitiesRequest,AnalyzeEntitiesResponse> analyzeEntitiesCallable()
Sample code:
// 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()) {
AnalyzeEntitiesRequest request =
AnalyzeEntitiesRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
ApiFuture<AnalyzeEntitiesResponse> future =
languageServiceClient.analyzeEntitiesCallable().futureCall(request);
// Do something.
AnalyzeEntitiesResponse response = future.get();
}
public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document)
Sample code:
// 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();
AnalyzeEntitySentimentResponse response =
languageServiceClient.analyzeEntitySentiment(document);
}
document
- Required. Input document.ApiException
- if the remote call failspublic final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document, EncodingType encodingType)
Sample code:
// 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();
EncodingType encodingType = EncodingType.forNumber(0);
AnalyzeEntitySentimentResponse response =
languageServiceClient.analyzeEntitySentiment(document, encodingType);
}
document
- Required. Input document.encodingType
- The encoding type used by the API to calculate offsets.ApiException
- if the remote call failspublic final AnalyzeEntitySentimentResponse analyzeEntitySentiment(AnalyzeEntitySentimentRequest request)
Sample code:
// 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()) {
AnalyzeEntitySentimentRequest request =
AnalyzeEntitySentimentRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
AnalyzeEntitySentimentResponse response =
languageServiceClient.analyzeEntitySentiment(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AnalyzeEntitySentimentRequest,AnalyzeEntitySentimentResponse> analyzeEntitySentimentCallable()
Sample code:
// 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()) {
AnalyzeEntitySentimentRequest request =
AnalyzeEntitySentimentRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
ApiFuture<AnalyzeEntitySentimentResponse> future =
languageServiceClient.analyzeEntitySentimentCallable().futureCall(request);
// Do something.
AnalyzeEntitySentimentResponse response = future.get();
}
public final AnalyzeSyntaxResponse analyzeSyntax(Document document)
Sample code:
// 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();
AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
}
document
- Required. Input document.ApiException
- if the remote call failspublic final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType encodingType)
Sample code:
// 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();
EncodingType encodingType = EncodingType.forNumber(0);
AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document, encodingType);
}
document
- Required. Input document.encodingType
- The encoding type used by the API to calculate offsets.ApiException
- if the remote call failspublic final AnalyzeSyntaxResponse analyzeSyntax(AnalyzeSyntaxRequest request)
Sample code:
// 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()) {
AnalyzeSyntaxRequest request =
AnalyzeSyntaxRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AnalyzeSyntaxRequest,AnalyzeSyntaxResponse> analyzeSyntaxCallable()
Sample code:
// 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()) {
AnalyzeSyntaxRequest request =
AnalyzeSyntaxRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
ApiFuture<AnalyzeSyntaxResponse> future =
languageServiceClient.analyzeSyntaxCallable().futureCall(request);
// Do something.
AnalyzeSyntaxResponse response = future.get();
}
public final ClassifyTextResponse classifyText(Document document)
Sample code:
// 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();
ClassifyTextResponse response = languageServiceClient.classifyText(document);
}
document
- Required. Input document.ApiException
- if the remote call failspublic final ClassifyTextResponse classifyText(ClassifyTextRequest request)
Sample code:
// 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()) {
ClassifyTextRequest request =
ClassifyTextRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
.build();
ClassifyTextResponse response = languageServiceClient.classifyText(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ClassifyTextRequest,ClassifyTextResponse> classifyTextCallable()
Sample code:
// 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()) {
ClassifyTextRequest request =
ClassifyTextRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
.build();
ApiFuture<ClassifyTextResponse> future =
languageServiceClient.classifyTextCallable().futureCall(request);
// Do something.
ClassifyTextResponse response = future.get();
}
public final AnnotateTextResponse annotateText(Document document, AnnotateTextRequest.Features features)
Sample code:
// 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();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
AnnotateTextResponse response = languageServiceClient.annotateText(document, features);
}
document
- Required. Input document.features
- Required. The enabled features.ApiException
- if the remote call failspublic final AnnotateTextResponse annotateText(Document document, AnnotateTextRequest.Features features, EncodingType encodingType)
Sample code:
// 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();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
EncodingType encodingType = EncodingType.forNumber(0);
AnnotateTextResponse response =
languageServiceClient.annotateText(document, features, encodingType);
}
document
- Required. Input document.features
- Required. The enabled features.encodingType
- The encoding type used by the API to calculate offsets.ApiException
- if the remote call failspublic final AnnotateTextResponse annotateText(AnnotateTextRequest request)
Sample code:
// 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()) {
AnnotateTextRequest request =
AnnotateTextRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setFeatures(AnnotateTextRequest.Features.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
AnnotateTextResponse response = languageServiceClient.annotateText(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AnnotateTextRequest,AnnotateTextResponse> annotateTextCallable()
Sample code:
// 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()) {
AnnotateTextRequest request =
AnnotateTextRequest.newBuilder()
.setDocument(Document.newBuilder().build())
.setFeatures(AnnotateTextRequest.Features.newBuilder().build())
.setEncodingType(EncodingType.forNumber(0))
.build();
ApiFuture<AnnotateTextResponse> future =
languageServiceClient.annotateTextCallable().futureCall(request);
// Do something.
AnnotateTextResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2022 Google LLC. All rights reserved.