Source:
public static void main(String[] args) { TextAnalyticsClient client = new TextAnalyticsClientBuilder() .subscriptionKey("<replace-with-your-text-analytics-key-here>") .endpoint("<replace-with-your-text-analytics-endpoint-here>") .buildClient(); List<TextDocumentInput> inputs = Arrays.asList( new TextDocumentInput("1", "My cat might need to see a veterinarian.", "en"), new TextDocumentInput("2", "The pitot tube is used to measure airspeed.", "en") ); final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); final DocumentResultCollection<ExtractKeyPhraseResult> extractedBatchResult = client.extractBatchKeyPhrasesWithResponse(inputs, requestOptions, Context.NONE).getValue(); System.out.printf("Model version: %s%n", extractedBatchResult.getModelVersion()); final TextDocumentBatchStatistics batchStatistics = extractedBatchResult.getStatistics(); System.out.printf("A batch of document statistics, document count: %s, erroneous document count: %s, transaction count: %s, valid document count: %s.%n", batchStatistics.getDocumentCount(), batchStatistics.getErroneousDocumentCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (ExtractKeyPhraseResult extractKeyPhraseResult : extractedBatchResult) { System.out.printf("Document ID: %s%n", extractKeyPhraseResult.getId()); final List<String> documentKeyPhrases = extractKeyPhraseResult.getKeyPhrases(); if (documentKeyPhrases == null) { System.out.printf("Cannot extract key phrases. Error: %s%n", extractKeyPhraseResult.getError().getMessage()); continue; } for (String keyPhrases : documentKeyPhrases) { System.out.printf("Extracted phrases: %s.%n", keyPhrases); } } }

Target:
public static void main(String[] args) { TextAnalyticsClient client = new TextAnalyticsClientBuilder() .subscriptionKey("{subscription_key}") .endpoint("https://{servicename}.cognitiveservices.azure.com/") .buildClient(); List<TextDocumentInput> inputs = Arrays.asList( new TextDocumentInput("1", "My cat might need to see a veterinarian.", "en"), new TextDocumentInput("2", "The pitot tube is used to measure airspeed.", "en") ); final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); final DocumentResultCollection<ExtractKeyPhraseResult> extractedBatchResult = client.extractBatchKeyPhrasesWithResponse(inputs, requestOptions, Context.NONE).getValue(); System.out.printf("Model version: %s%n", extractedBatchResult.getModelVersion()); final TextDocumentBatchStatistics batchStatistics = extractedBatchResult.getStatistics(); System.out.printf("A batch of document statistics, document count: %s, erroneous document count: %s, transaction count: %s, valid document count: %s.%n", batchStatistics.getDocumentCount(), batchStatistics.getErroneousDocumentCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (ExtractKeyPhraseResult extractKeyPhraseResult : extractedBatchResult) { System.out.printf("Document ID: %s%n", extractKeyPhraseResult.getId()); if (extractKeyPhraseResult.isError()) { System.out.printf("Cannot extract key phrases. Error: %s%n", extractKeyPhraseResult.getError().getMessage()); continue; } for (String keyPhrases : extractKeyPhraseResult.getKeyPhrases()) { System.out.printf("Extracted phrases: %s.%n", keyPhrases); } } }