From 32dd65ef253546290c209f15776df87fa2c73def Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Mon, 6 Jan 2020 15:24:18 -0800 Subject: [PATCH 1/9] adding code snippets for async methods --- .../TextAnalyticsAsyncClient.java | 192 ++++ ...alyticsAsyncClientJavaDocCodeSnippets.java | 975 ++++++++++++++++++ 2 files changed, 1167 insertions(+) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java index 34e03ee54dd39..6552625c63785 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java @@ -110,6 +110,12 @@ public TextAnalyticsServiceVersion getServiceVersion() { * Returns the detected language and a numeric score between zero and one. Scores close to one indicate 100% * certainty that the identified language is true. * + *

Code sample

+ *

Detects languages in a text. Subscribes to the call asynchronously and prints out the detected language + * details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguage#string} + * * @param text The text to be analyzed. * * @return A {@link Mono} containing the {@link DetectLanguageResult detected language} of the text. @@ -129,6 +135,12 @@ public Mono detectLanguage(String text) { * Returns a {@link Response} containing the detected language and a numeric score between zero and one. Scores * close to one indicate 100% certainty that the identified language is true. * + *

Code sample

+ *

Detects languages with http response in a text with a provided country hint. Subscribes to the call + * asynchronously and prints out the detected language details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguageWithResponse#string-string} + * * @param text The text to be analyzed. * @param countryHint Accepts two letter country codes specified by ISO 3166-1 alpha-2. Defaults to "US" if not * specified. @@ -151,6 +163,12 @@ public Mono> detectLanguageWithResponse(String te /** * Returns the detected language for a batch of input. * + *

Code sample

+ *

Detects languages in a list of string inputs. Subscribes to the call asynchronously and prints out the + * detected language details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List} + * * @param textInputs The list of texts to be analyzed. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -170,6 +188,12 @@ public Mono> detectLanguages(List /** * Returns the detected language for a batch of input with the provided country hint. * + *

Code sample

+ *

Detects languages in a list of string inputs with a provided country hint for the batch. Subscribes to the + * call asynchronously and prints out the detected language details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguagesWithResponse#List-String} + * * @param textInputs The list of texts to be analyzed. * @param countryHint A country hint for the entire batch. Accepts two letter country codes specified by ISO * 3166-1 alpha-2. Defaults to "US" if not specified. @@ -193,6 +217,12 @@ public Mono>> detectLang /** * Returns the detected language for a batch of input. * + *

Code sample

+ *

Detects languages in a list of DetectLanguageInput. Subscribes to the call asynchronously and prints out + * the detected language details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List} + * * @param textInputs The list of {@link DetectLanguageInput inputs/documents} to be analyzed. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -213,6 +243,12 @@ public Mono> detectBatchLanguages /** * Returns the detected language for a batch of input. * + *

Code sample

+ *

Detects languages in a text. Subscribes to the call asynchronously and prints out the detected language + * details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguagesWithResponse#List-TextAnalyticsRequestOptions} + * * @param textInputs The list of {@link DetectLanguageInput inputs/documents} to be analyzed. * @param options The {@link TextAnalyticsRequestOptions options} to configure the scoring model for documents * and show statistics. @@ -239,6 +275,12 @@ public Mono>> detectBatc * . For a list of enabled languages, * check: * + *

Code sample

+ *

Recognize entities in a text. Subscribes to the call asynchronously and prints out the recognized entity + * details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#string} + * * @param text the text to recognize entities for. * * @return A {@link Mono} containing the {@link RecognizeEntitiesResult named entity} of the text. @@ -259,6 +301,12 @@ public Mono recognizeEntities(String text) { * . For a list of enabled languages, * check: * + *

Code sample

+ *

Recognize entities in a text with provided language hint. Subscribes to the call asynchronously and prints out + * the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string} + * * @param text the text to recognize entities for. * @param language The 2 letter ISO 639-1 representation of language. If not set, uses "en" for English as * default. @@ -281,6 +329,12 @@ public Mono> recognizeEntitiesWithResponse(Str /** * Returns a list of general named entities for the provided list of texts. * + *

Code sample

+ *

Recognize entities in a text. Subscribes to the call asynchronously and prints out the entity details + * when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List} + * * @param textInputs A list of texts to recognize entities for. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -300,6 +354,12 @@ public Mono> recognizeEntities /** * Returns a list of general named entities for the provided list of texts. * + *

Code sample

+ *

Recognize entities in a text with the provided language hint. Subscribes to the call asynchronously and + * prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#List-String} + * * @param textInputs A list of texts to recognize entities for. * @param language The 2 letter ISO 639-1 representation of language. If not set, uses "en" for English as * default. @@ -323,6 +383,12 @@ public Mono>> recogni /** * Returns a list of general named entities for the provided list of text inputs. * + *

Code sample

+ *

Recognize entities in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to recognize entities for. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -343,6 +409,12 @@ public Mono> recognizeBatchEnt /** * Returns a list of general named entities for the provided list of text inputs. * + *

Code sample

+ *

Recognize entities in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntitiesWithResponse#List-TextAnalyticsRequestOptions} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to recognize entities for. * @param options The {@link TextAnalyticsRequestOptions options} to configure the scoring model for documents * and show statistics. @@ -369,6 +441,11 @@ public Mono>> recogni * supported entity types, check . See * for the list of enabled languages. * + *

Recognize pii entities in a text. Subscribes to the call asynchronously and prints out the + * entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#string} + * * @param text the text to recognize PII entities for. * * @return A {@link Mono} containing the {@link RecognizeEntitiesResult PII entity} of the text. @@ -389,6 +466,11 @@ public Mono recognizePiiEntities(String text) { * supported entity types, check: . For a list of enabled languages, * check: . * + *

Recognize pii entities in a text with provided language hint. Subscribes to the call asynchronously and + * prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string} + * * @param text the text to recognize PII entities for. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -413,6 +495,11 @@ public Mono> recognizePiiEntitiesWithRespon * of supported entity types, check: . For a list of enabled languages, * check: for the list of enabled languages. * + *

Recognize pii entities in a list of string inputs. Subscribes to the call asynchronously and prints out the + * entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string} + * * @param textInputs A list of text to recognize PII entities for. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -435,6 +522,11 @@ public Mono> recognizePiiEn * of supported entity types, check . For a list of enabled languages, * check: . * + *

Recognize pii entities in a list of string inputs with provided language hint. Subscribes to the call + * asynchronously and prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String} + * * @param textInputs A list of text to recognize PII entities for. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -460,6 +552,11 @@ public Mono>> reco * the list of supported entity types, check: * For a list of enabled languages, check: . * + *

Recognize pii entities in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out + * the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to recognize PII entities for. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -482,6 +579,11 @@ public Mono> recognizeBatch * the list of supported entity types,check: . For a list of enabled languages, * check: . * + *

Recognize pii entities in a list of TextDocumentInput with provided statistics options. Subscribes to the + * call asynchronously and prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse#List-TextAnalyticsRequestOptions} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to recognize PII entities for. * @param options The {@link TextAnalyticsRequestOptions options} to configure the scoring model for documents * and show statistics. @@ -507,6 +609,11 @@ public Mono>> reco * Returns a list of recognized entities with links to a well-known knowledge base for the provided text. See * for supported languages in Text Analytics API. * + *

Recognize linked entities in a text. Subscribes to the call asynchronously and prints out the + * entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#string} + * * @param text the text to recognize linked entities for. * * @return A {@link Mono} containing the {@link RecognizeLinkedEntitiesResult linked entity} of the text. @@ -526,6 +633,11 @@ public Mono recognizeLinkedEntities(String text) * Returns a list of recognized entities with links to a well-known knowledge base for the provided text. See * for supported languages in Text Analytics API. * + *

Recognize linked entities in a text with provided language hint. Subscribes to the call asynchronously + * and prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#string-string} + * * @param text the text to recognize linked entities for. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -550,6 +662,11 @@ public Mono> recognizeLinkedEntitiesWith * Returns a list of recognized entities with links to a well-known knowledge base for the list of texts. See * for supported languages in Text Analytics API. * + *

Recognize linked entities in a list of string inputs. Subscribes to the call asynchronously and prints out the + * entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string} + * * @param textInputs A list of text to recognize linked entities for. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -572,6 +689,11 @@ public Mono> recognizeLi * Returns a list of recognized entities with links to a well-known knowledge base for the list of texts. See * for supported languages in Text Analytics API. * + *

Recognize linked entities in a list of string inputs with provided language hint. Subscribes to the call + * asynchronously and prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#List-String} + * * @param textInputs A list of text to recognize linked entities for. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -596,6 +718,11 @@ public Mono>> r * Returns a list of recognized entities with links to a well-known knowledge base for the list of inputs. See * for supported languages in Text Analytics API. * + *

Recognize linked entities in a list of TextDocumentInput. Subscribes to the call asynchronously and + * prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntities#List} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to recognize linked entities for. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -617,6 +744,11 @@ public Mono> recognizeBa * Returns a list of recognized entities with links to a well-known knowledge base for the list of inputs. See * supported languages in Text Analytics API. * + *

Recognize linked entities in a list of TextDocumentInput and provided reuqest options to show statistics. + * Subscribes to the call asynchronously and prints out the entity details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntitiesWithResponse#List-TextAnalyticsRequestOptions} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to recognize linked entities for. * @param options The {@link TextAnalyticsRequestOptions options} to configure the scoring model for documents * and show statistics. @@ -642,6 +774,11 @@ public Mono> recognizeBa /** * Returns a list of strings denoting the key phrases in the input text. * + *

Extract key phrases in a text. Subscribes to the call asynchronously and prints out the + * key phrases when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#string} + * * @param text the text to be analyzed. * * @return A {@link Mono} containing the {@link ExtractKeyPhraseResult key phrases} of the text. @@ -661,6 +798,11 @@ public Mono extractKeyPhrases(String text) { * Returns a list of strings denoting the key phrases in the input text. See * for the list of enabled languages. * + *

Extract key phrases in a text with a provided language. Subscribes to the call asynchronously and prints + * out the key phrases when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#string-string} + * * @param text the text to be analyzed. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -683,6 +825,11 @@ public Mono> extractKeyPhrasesWithResponse(Stri /** * Returns a list of strings denoting the key phrases in the input text. * + *

Extract key phrases in a list of string inputs. Subscribes to the call asynchronously and prints out the + * key phrases when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string} + * * @param textInputs A list of text to be analyzed. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -703,6 +850,11 @@ public Mono> extractKeyPhrases( * Returns a list of strings denoting the key phrases in the input text. See * for the list of enabled languages. * + *

Extract key phrases in a list of string inputs with a provided language. Subscribes to the call asynchronously + * and prints out the key phrases when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#List-String} + * * @param textInputs A list of text to be analyzed. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -726,6 +878,11 @@ public Mono>> extractK /** * Returns a list of strings denoting the key phrases in the input text. * + *

Extract key phrases in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * key phrases when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrases#List} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to be analyzed. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -747,6 +904,11 @@ public Mono> extractBatchKeyPhr * Returns a list of strings denoting the key phrases in the input text. See * for the list of enabled languages. * + *

Extract key phrases in a list of TextDocumentInput with request options. Subscribes to the call asynchronously + * and prints out the key phrases when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrasesWithResponse#List-TextAnalyticsRequestOptions} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to be analyzed. * @param options The {@link TextAnalyticsRequestOptions options} to configure the scoring model for documents * and show statistics. @@ -772,6 +934,11 @@ public Mono>> extractB * Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and * Neutral) for the document and each sentence within i * + *

Analyze sentiment in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * sentiment details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#string} + * * @param text the text to be analyzed. * * @return A {@link Mono} containing the {@link AnalyzeSentimentResult text sentiment} of the text. @@ -791,6 +958,11 @@ public Mono analyzeSentiment(String text) { * Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and * Neutral) for the document and each sentence within i * + *

Analyze sentiment in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * sentiment details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#string-string} + * * @param text the text to be analyzed. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -814,6 +986,11 @@ public Mono> analyzeSentimentWithResponse(Strin * Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and * Neutral) for the document and each sentence within it. * + *

Analyze sentiment in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * sentiment details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string} + * * @param textInputs A list of text to be analyzed. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -834,6 +1011,11 @@ public Mono> analyzeSentiment(L * Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and * Neutral) for the document and each sentence within it. * + *

Analyze sentiment in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * sentiment details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#List-String} + * * @param textInputs A list of text to be analyzed. * @param language The 2 letter ISO 639-1 representation of language for the text. If not set, uses "en" for * English as default. @@ -858,6 +1040,11 @@ public Mono>> analyzeS * Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and * Neutral) for the document and each sentence within it. * + *

Analyze sentiment in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out the + * sentiment details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentiment#List} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to be analyzed. * * @return A {@link Mono} containing the {@link DocumentResultCollection batch} of the @@ -879,6 +1066,11 @@ public Mono> analyzeBatchSentim * Returns a sentiment prediction, as well as sentiment scores for each sentiment class (Positive, Negative, and * Neutral) for the document and each sentence within it. * + *

Analyze sentiment in a list of TextDocumentInput with provided request options. Subscribes to the call + * asynchronously and prints out the sentiment details when a response is received.

+ * + * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentimentWithResponse#List-TextAnalyticsRequestOptions} + * * @param textInputs A list of {@link TextDocumentInput inputs/documents} to be analyzed. * @param options The {@link TextAnalyticsRequestOptions options} to configure the scoring model for documents * and show statistics. diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index 9be79bf295fcb..5c911a5a81ef8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -3,6 +3,25 @@ package com.azure.ai.textanalytics; +import com.azure.ai.textanalytics.models.AnalyzeSentimentResult; +import com.azure.ai.textanalytics.models.DetectLanguageInput; +import com.azure.ai.textanalytics.models.DetectLanguageResult; +import com.azure.ai.textanalytics.models.DetectedLanguage; +import com.azure.ai.textanalytics.models.DocumentResultCollection; +import com.azure.ai.textanalytics.models.ExtractKeyPhraseResult; +import com.azure.ai.textanalytics.models.LinkedEntity; +import com.azure.ai.textanalytics.models.NamedEntity; +import com.azure.ai.textanalytics.models.RecognizeEntitiesResult; +import com.azure.ai.textanalytics.models.RecognizeLinkedEntitiesResult; +import com.azure.ai.textanalytics.models.RecognizePiiEntitiesResult; +import com.azure.ai.textanalytics.models.TextAnalyticsRequestOptions; +import com.azure.ai.textanalytics.models.TextDocumentBatchStatistics; +import com.azure.ai.textanalytics.models.TextDocumentInput; +import com.azure.ai.textanalytics.models.TextSentiment; + +import java.util.Arrays; +import java.util.List; + /** * Code snippet for {@link TextAnalyticsAsyncClient} */ @@ -24,4 +43,960 @@ public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.instantiation return textAnalyticsAsyncClient; } + + // Languages + + /** + * Code snippet for detecting Language + */ + public void detectLanguageCodeSnippets() { + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguage#string + String inputText = "Bonjour tout le monde"; + textAnalyticsAsyncClient.detectLanguage(inputText).subscribe(detectLanguageResult -> { + for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { + System.out.printf("Detected languages name: %s, ISO 6391 Name: %s, Score: %s.%n", + detectedLanguage.getName(), + detectedLanguage.getIso6391Name(), + detectedLanguage.getScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguage#string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguageWithResponse#string-string + String input = "This text is in English"; + String countryHint = "US"; + textAnalyticsAsyncClient.detectLanguageWithResponse(input, countryHint).subscribe(detectLanguageResult -> { + for (DetectedLanguage detectedLanguage : detectLanguageResult.getValue().getDetectedLanguages()) { + System.out.printf("Detected languages name: %s, ISO 6391 Name: %s, Score: %s.%n", + detectedLanguage.getName(), + detectedLanguage.getIso6391Name(), + detectedLanguage.getScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguageWithResponse#string-string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List + final List inputs = Arrays.asList( + "This is written in English", "Este es un document escrito en Español."); + textAnalyticsAsyncClient.detectLanguages(inputs).subscribe(detectedBatchResult -> { + System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); + System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," + + " transaction count: %s, valid document count: %s.%n", + batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), + batchStatistics.getValidDocumentCount()); + + for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { + for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { + System.out.printf("Another detected language: %s, ISO 6391 name: %s, score: %s.%n", + detectedLanguage.getName(), + detectedLanguage.getIso6391Name(), + detectedLanguage.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguagesWithResponse#List-String + final List listInputs = Arrays.asList( + "This is written in English", "Este es un document escrito en Español."); + textAnalyticsAsyncClient.detectLanguagesWithResponse(listInputs, "US").subscribe(response -> { + DocumentResultCollection detectedBatchResult = response.getValue(); + System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); + System.out.printf("Batch 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 (DetectLanguageResult detectLanguageResult : detectedBatchResult) { + for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { + System.out.printf("Another detected language: %s, ISO 6391 name: %s, score: %s.%n", + detectedLanguage.getName(), + detectedLanguage.getIso6391Name(), + detectedLanguage.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguagesWithResponse#List-String + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List + List detectLanguageInputs = Arrays.asList( + new DetectLanguageInput("1", "This is written in English.", "us"), + new DetectLanguageInput("2", "Este es un document escrito en Español.", "es") + ); + textAnalyticsAsyncClient.detectBatchLanguages(detectLanguageInputs).subscribe(detectedBatchResult -> { + System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); + System.out.printf("Batch 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 (DetectLanguageResult detectLanguageResult : detectedBatchResult) { + for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { + System.out.printf("Another detected language: %s, ISO 6391 name: %s, score: %s.%n", + detectedLanguage.getName(), + detectedLanguage.getIso6391Name(), + detectedLanguage.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguagesWithResponse#List-TextAnalyticsRequestOptions + List detectLanguageInputs1 = Arrays.asList( + new DetectLanguageInput("1", "This is written in English.", "US"), + new DetectLanguageInput("2", "Este es un document escrito en Español.", "es") + ); + + // Request options: show statistics and model version + final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); + + textAnalyticsAsyncClient.detectBatchLanguagesWithResponse(detectLanguageInputs1, requestOptions) + .subscribe(response -> { + final DocumentResultCollection detectedBatchResult = response.getValue(); + System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); + System.out.printf("Batch 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 (DetectLanguageResult detectLanguageResult : detectedBatchResult) { + for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { + System.out.printf("Other detected language: %s, ISO 6391 name: %s, score: %s.%n", + detectedLanguage.getName(), + detectedLanguage.getIso6391Name(), + detectedLanguage.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguagesWithResponse#List-TextAnalyticsRequestOptions + } + + // Entity + + /** + * Code snippet for recognizing entities + */ + public void recognizeEntitiesCodeSnippets() { + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#string + String inputText = "Satya Nadella is the CEO of Microsoft"; + textAnalyticsAsyncClient.recognizeEntities(inputText).subscribe(recognizeEntitiesResult -> { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string + String inputText1 = "Satya Nadella is the CEO of Microsoft"; + textAnalyticsAsyncClient.recognizeEntitiesWithResponse(inputText1, "US") + .subscribe(recognizeEntitiesResult -> { + for (NamedEntity entity : recognizeEntitiesResult.getValue().getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string + + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List + List inputs = Arrays.asList( + "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + + textAnalyticsAsyncClient.recognizeEntities(inputs).subscribe(recognizeEntitiesResults -> { + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " + + "transaction count: %s, valid document count: %s.%n", + batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), + batchStatistics.getValidDocumentCount()); + + for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#List-String + List inputs1 = Arrays.asList( + "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + + textAnalyticsAsyncClient.recognizeEntitiesWithResponse(inputs1, "en").subscribe(response -> { + DocumentResultCollection recognizeEntitiesResults = response.getValue(); + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#List-String + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List + List textDocumentInputs = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntitiesWithResponse#List-TextAnalyticsRequestOptions + List textDocumentInputs1 = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + // Request options: show statistics and model version + final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); + + textAnalyticsAsyncClient.recognizeBatchEntitiesWithResponse(textDocumentInputs1, requestOptions) + .subscribe(response -> { + final DocumentResultCollection recognizeEntitiesResults = response.getValue(); + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntitiesWithResponse#List-TextAnalyticsRequestOptions + } + + // Pii Entity + + /** + * Code snippet for recognizing entities + */ + public void recognizePiiEntitiesCodeSnippets() { + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#string + String inputText = "My SSN is 555-55-5555"; + textAnalyticsAsyncClient.recognizePiiEntities(inputText).subscribe(recognizeEntitiesResult -> { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string + String inputText1 = "My SSN is 555-55-5555"; + textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(inputText1, "US") + .subscribe(recognizeEntitiesResult -> { + for (NamedEntity entity : recognizeEntitiesResult.getValue().getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string + + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string + List inputs = Arrays.asList( + "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + + textAnalyticsAsyncClient.recognizePiiEntities(inputs).subscribe(recognizeEntitiesResults -> { + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " + + "transaction count: %s, valid document count: %s.%n", + batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), + batchStatistics.getValidDocumentCount()); + + for (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String + List inputs1 = Arrays.asList( + "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + + textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(inputs1, "en").subscribe(response -> { + DocumentResultCollection recognizeEntitiesResults = response.getValue(); + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List + List textDocumentInputs = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + textAnalyticsAsyncClient.recognizeBatchPiiEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse#List-TextAnalyticsRequestOptions + List textDocumentInputs1 = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + // Request options: show statistics and model version + final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); + + textAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse(textDocumentInputs1, requestOptions) + .subscribe(response -> { + DocumentResultCollection recognizeEntitiesResults = response.getValue(); + System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { + for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { + System.out.printf( + "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + entity.getText(), + entity.getType(), + entity.getSubtype(), + entity.getScore()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse#List-TextAnalyticsRequestOptions + } + + // Linked Entity + + /** + * Code snippet for recognizing entities + */ + public void recognizeLinkedEntitiesCodeSnippets() { + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#string + String inputText = "Old Faithful is a geyser at Yellowstone Park."; + textAnalyticsAsyncClient.recognizeLinkedEntities(inputText).subscribe(recognizeEntitiesResult -> { + for (LinkedEntity linkedEntity : recognizeEntitiesResult.getLinkedEntities()) { + System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", + linkedEntity.getName(), + linkedEntity.getUrl(), + linkedEntity.getDataSource()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#string-string + String inputText1 = "Old Faithful is a geyser at Yellowstone Park."; + textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(inputText1, "US") + .subscribe(linkedEntitiesResultResponse -> { + for (LinkedEntity linkedEntity : linkedEntitiesResultResponse.getValue().getLinkedEntities()) { + System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", + linkedEntity.getName(), + linkedEntity.getUrl(), + linkedEntity.getDataSource()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#string-string + + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string + List inputs = Arrays.asList( + "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + + textAnalyticsAsyncClient.recognizeLinkedEntities(inputs).subscribe(recognizeLinkedEntitiesResults -> { + System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); + + // Batch statistics + TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); + System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," + + " transaction count: %s, valid document count: %s.%n", + batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), + batchStatistics.getValidDocumentCount()); + + for (RecognizeLinkedEntitiesResult recognizeLinkedEntitiesResult : recognizeLinkedEntitiesResults) { + for (LinkedEntity linkedEntity : recognizeLinkedEntitiesResult.getLinkedEntities()) { + System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", + linkedEntity.getName(), + linkedEntity.getUrl(), + linkedEntity.getDataSource()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#List-String + List inputs1 = Arrays.asList( + "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + + textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(inputs1, "en").subscribe(response -> { + DocumentResultCollection recognizeLinkedEntitiesResults = response.getValue(); + System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); + + // Batch statistics + TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizeLinkedEntitiesResult recognizeLinkedEntitiesResult : recognizeLinkedEntitiesResults) { + for (LinkedEntity linkedEntity : recognizeLinkedEntitiesResult.getLinkedEntities()) { + System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", + linkedEntity.getName(), + linkedEntity.getUrl(), + linkedEntity.getDataSource()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#List-String + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntities#List + List textDocumentInputs = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + textAnalyticsAsyncClient.recognizeBatchLinkedEntities(textDocumentInputs) + .subscribe(recognizeLinkedEntitiesResults -> { + System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizeLinkedEntitiesResult recognizeLinkedEntitiesResult : recognizeLinkedEntitiesResults) { + for (LinkedEntity linkedEntity : recognizeLinkedEntitiesResult.getLinkedEntities()) { + System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", + linkedEntity.getName(), + linkedEntity.getUrl(), + linkedEntity.getDataSource()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntities#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntitiesWithResponse#List-TextAnalyticsRequestOptions + List textDocumentInputs1 = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + // Request options: show statistics and model version + final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); + + textAnalyticsAsyncClient.recognizeBatchLinkedEntitiesWithResponse(textDocumentInputs1, requestOptions) + .subscribe(response -> { + DocumentResultCollection recognizeLinkedEntitiesResults = + response.getValue(); + System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); + System.out.printf("Batch 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 (RecognizeLinkedEntitiesResult recognizeLinkedEntitiesResult : recognizeLinkedEntitiesResults) { + for (LinkedEntity linkedEntity : recognizeLinkedEntitiesResult.getLinkedEntities()) { + System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", + linkedEntity.getName(), + linkedEntity.getUrl(), + linkedEntity.getDataSource()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntitiesWithResponse#List-TextAnalyticsRequestOptions + } + + // Key Phrases + + /** + * Code snippet for recognizing entities + */ + public void extractKeyPhrasesCodeSnippets() { + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#string + String inputText = "Bonjour tout le monde"; + textAnalyticsAsyncClient.extractKeyPhrases(inputText).subscribe(extractKeyPhraseResult -> { + for (String keyPhrase : extractKeyPhraseResult.getKeyPhrases()) { + System.out.printf("Recognized phrases: %s.%n", keyPhrase); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#string-string + String inputText1 = "Bonjour tout le monde"; + textAnalyticsAsyncClient.extractKeyPhrasesWithResponse(inputText1, "fr") + .subscribe(keyPhraseResultResponse -> { + for (String keyPhrase : keyPhraseResultResponse.getValue().getKeyPhrases()) { + System.out.printf("Recognized phrases: %s.%n", keyPhrase); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#string-string + + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string + List inputs = Arrays.asList( + "Hello world. This is some input text that I love.", + "Bonjour tout le monde"); + + textAnalyticsAsyncClient.extractKeyPhrases(inputs).subscribe(extractKeyPhraseResults -> { + System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," + + " transaction count: %s, valid document count: %s.%n", + batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), + batchStatistics.getValidDocumentCount()); + + for (ExtractKeyPhraseResult extractKeyPhraseResult : extractKeyPhraseResults) { + for (String keyPhrase : extractKeyPhraseResult.getKeyPhrases()) { + System.out.printf("Recognized phrases: %s.%n", keyPhrase); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#List-String + List inputs1 = Arrays.asList( + "Hello world. This is some input text that I love.", + "Bonjour tout le monde"); + + textAnalyticsAsyncClient.extractKeyPhrasesWithResponse(inputs1, "en").subscribe(response -> { + DocumentResultCollection extractKeyPhraseResults = response.getValue(); + System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + System.out.printf("Batch 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 : extractKeyPhraseResults) { + for (String keyPhrase : extractKeyPhraseResult.getKeyPhrases()) { + System.out.printf("Recognized phrases: %s.%n", keyPhrase); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#List-String + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrases#List + List textDocumentInputs = Arrays.asList( + new TextDocumentInput("0", "Hello world. This is some input text that I love."), + new TextDocumentInput("1", "I work at Microsoft.")); + + textAnalyticsAsyncClient.extractBatchKeyPhrases(textDocumentInputs).subscribe(extractKeyPhraseResults -> { + System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + System.out.printf("Batch 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 : extractKeyPhraseResults) { + for (String keyPhrase : extractKeyPhraseResult.getKeyPhrases()) { + System.out.printf("Recognized phrases: %s.%n", keyPhrase); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrases#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrasesWithResponse#List-TextAnalyticsRequestOptions + List textDocumentInputs1 = Arrays.asList( + new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), + new TextDocumentInput("1", "I work at Microsoft.")); + + // Request options: show statistics and model version + final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); + + textAnalyticsAsyncClient.extractBatchKeyPhrasesWithResponse(textDocumentInputs1, requestOptions) + .subscribe(response -> { + final DocumentResultCollection extractKeyPhraseResults = response.getValue(); + System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + System.out.printf("Batch 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 : extractKeyPhraseResults) { + for (String keyPhrase : extractKeyPhraseResult.getKeyPhrases()) { + System.out.printf("Recognized phrases: %s.%n", keyPhrase); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrasesWithResponse#List-TextAnalyticsRequestOptions + } + + // Sentiment + + /** + * Code snippet for recognizing entities + */ + public void analyzeSentimentCodeSnippets() { + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#string + String inputText = "The hotel was dark and unclean."; + textAnalyticsAsyncClient.analyzeSentiment(inputText).subscribe(analyzeSentimentResult -> { + TextSentiment documentSentiment = analyzeSentimentResult.getDocumentSentiment(); + System.out.printf( + "Recognized sentiment class: %s.%n", + documentSentiment.getTextSentimentClass()); + + for (TextSentiment textSentiment : analyzeSentimentResult.getSentenceSentiments()) { + System.out.printf( + "Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, negative score: %s.%n", + textSentiment.getTextSentimentClass(), + textSentiment.getPositiveScore(), + textSentiment.getNeutralScore(), + textSentiment.getNegativeScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#string-string + String inputText1 = "The hotel was dark and unclean."; + textAnalyticsAsyncClient.analyzeSentimentWithResponse(inputText1, "en") + .subscribe(analyzeSentimentResult -> { + AnalyzeSentimentResult sentimentResult = analyzeSentimentResult.getValue(); + TextSentiment documentSentiment = sentimentResult.getDocumentSentiment(); + System.out.printf( + "Recognized sentiment class: %s.%n", + documentSentiment.getTextSentimentClass()); + + for (TextSentiment textSentiment : sentimentResult.getSentenceSentiments()) { + System.out.printf( + "Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " + + "negative score: %s.%n", + textSentiment.getTextSentimentClass(), + textSentiment.getPositiveScore(), + textSentiment.getNeutralScore(), + textSentiment.getNegativeScore()); + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#string-string + + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string + List inputs = Arrays.asList( + "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); + + textAnalyticsAsyncClient.analyzeSentiment(inputs).subscribe(analyzeSentimentResults -> { + System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," + + " transaction count: %s, valid document count: %s.%n", + batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), + batchStatistics.getValidDocumentCount()); + + for (AnalyzeSentimentResult analyzeSentimentResult : analyzeSentimentResults) { + System.out.printf("Document ID: %s%n", analyzeSentimentResult.getId()); + TextSentiment documentSentiment = analyzeSentimentResult.getDocumentSentiment(); + System.out.printf("Recognized document sentiment: %s.%n", + documentSentiment.getTextSentimentClass()); + for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { + System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " + + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + sentenceSentiment.getTextSentimentClass(), + sentenceSentiment.getPositiveScore(), + sentenceSentiment.getNeutralScore(), + sentenceSentiment.getNegativeScore(), + sentenceSentiment.getLength(), + sentenceSentiment.getOffset()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#List-String + List inputs1 = Arrays.asList( + "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); + + textAnalyticsAsyncClient.analyzeSentimentWithResponse(inputs1, "en").subscribe(response -> { + DocumentResultCollection analyzeSentimentResults = response.getValue(); + System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + System.out.printf("Batch 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 (AnalyzeSentimentResult analyzeSentimentResult : analyzeSentimentResults) { + System.out.printf("Document ID: %s%n", analyzeSentimentResult.getId()); + TextSentiment documentSentiment = analyzeSentimentResult.getDocumentSentiment(); + System.out.printf("Recognized document sentiment: %s.%n", + documentSentiment.getTextSentimentClass()); + for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { + System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " + + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + sentenceSentiment.getTextSentimentClass(), + sentenceSentiment.getPositiveScore(), + sentenceSentiment.getNeutralScore(), + sentenceSentiment.getNegativeScore(), + sentenceSentiment.getLength(), + sentenceSentiment.getOffset()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#List-String + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentiment#List + List textDocumentInputs = Arrays.asList( + new TextDocumentInput("0", "The hotel was dark and unclean."), + new TextDocumentInput("1", "The restaurant had amazing gnocchi.")); + + textAnalyticsAsyncClient.analyzeBatchSentiment(textDocumentInputs).subscribe(analyzeSentimentResults -> { + System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); + + // Batch statistics + final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + System.out.printf("Batch 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 (AnalyzeSentimentResult analyzeSentimentResult : analyzeSentimentResults) { + System.out.printf("Document ID: %s%n", analyzeSentimentResult.getId()); + TextSentiment documentSentiment = analyzeSentimentResult.getDocumentSentiment(); + System.out.printf("Recognized document sentiment: %s.%n", + documentSentiment.getTextSentimentClass()); + for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { + System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " + + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + sentenceSentiment.getTextSentimentClass(), + sentenceSentiment.getPositiveScore(), + sentenceSentiment.getNeutralScore(), + sentenceSentiment.getNegativeScore(), + sentenceSentiment.getLength(), + sentenceSentiment.getOffset()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentiment#List + + // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentimentWithResponse#List-TextAnalyticsRequestOptions + List textDocumentInputs1 = Arrays.asList( + new TextDocumentInput("0", "The hotel was dark and unclean."), + new TextDocumentInput("1", "The restaurant had amazing gnocchi.")); + + // Request options: show statistics and model version + final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); + + textAnalyticsAsyncClient.analyzeBatchSentimentWithResponse(textDocumentInputs1, requestOptions) + .subscribe(response -> { + DocumentResultCollection analyzeSentimentResults = response.getValue(); + System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); + + // Batch statistics + TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + System.out.printf("Batch 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 (AnalyzeSentimentResult analyzeSentimentResult : analyzeSentimentResults) { + System.out.printf("Document ID: %s%n", analyzeSentimentResult.getId()); + TextSentiment documentSentiment = analyzeSentimentResult.getDocumentSentiment(); + System.out.printf("Recognized document sentiment: %s.%n", + documentSentiment.getTextSentimentClass()); + for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { + System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " + + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + sentenceSentiment.getTextSentimentClass(), + sentenceSentiment.getPositiveScore(), + sentenceSentiment.getNeutralScore(), + sentenceSentiment.getNegativeScore(), + sentenceSentiment.getLength(), + sentenceSentiment.getOffset()); + } + } + }); + // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentimentWithResponse#List-TextAnalyticsRequestOptions + } } From 7a2b8aa7c41f4d5741cf82f5a01d14d199368f10 Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Mon, 6 Jan 2020 15:33:09 -0800 Subject: [PATCH 2/9] remove javadoc suppression --- .../main/resources/checkstyle/checkstyle-suppressions.xml | 2 -- .../TextAnalyticsAsyncClientJavaDocCodeSnippets.java | 8 ++++---- .../textanalytics/batch/DetectLanguageBatchDocuments.java | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index 5c4752c84813e..437b118c9692f 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -267,8 +267,6 @@ - - diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index 5c911a5a81ef8..0b787bf935f03 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -131,7 +131,7 @@ public void detectLanguageCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List List detectLanguageInputs = Arrays.asList( - new DetectLanguageInput("1", "This is written in English.", "us"), + new DetectLanguageInput("1", "This is written in English.", "US"), new DetectLanguageInput("2", "Este es un document escrito en Español.", "es") ); textAnalyticsAsyncClient.detectBatchLanguages(detectLanguageInputs).subscribe(detectedBatchResult -> { @@ -216,7 +216,7 @@ public void recognizeEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string String inputText1 = "Satya Nadella is the CEO of Microsoft"; - textAnalyticsAsyncClient.recognizeEntitiesWithResponse(inputText1, "US") + textAnalyticsAsyncClient.recognizeEntitiesWithResponse(inputText1, "en") .subscribe(recognizeEntitiesResult -> { for (NamedEntity entity : recognizeEntitiesResult.getValue().getNamedEntities()) { System.out.printf( @@ -378,7 +378,7 @@ public void recognizePiiEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string String inputText1 = "My SSN is 555-55-5555"; - textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(inputText1, "US") + textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(inputText1, "en") .subscribe(recognizeEntitiesResult -> { for (NamedEntity entity : recognizeEntitiesResult.getValue().getNamedEntities()) { System.out.printf( @@ -538,7 +538,7 @@ public void recognizeLinkedEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#string-string String inputText1 = "Old Faithful is a geyser at Yellowstone Park."; - textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(inputText1, "US") + textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(inputText1, "en") .subscribe(linkedEntitiesResultResponse -> { for (LinkedEntity linkedEntity : linkedEntitiesResultResponse.getValue().getLinkedEntities()) { System.out.printf("Recognized Linked NamedEntity: %s, URL: %s, Data Source: %s.%n", diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/batch/DetectLanguageBatchDocuments.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/batch/DetectLanguageBatchDocuments.java index a33ce2f8ea6bb..48574f724ca93 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/batch/DetectLanguageBatchDocuments.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/batch/DetectLanguageBatchDocuments.java @@ -34,8 +34,8 @@ public static void main(String[] args) { // The texts that need be analysed. List inputs = Arrays.asList( - new DetectLanguageInput("1", "This is written in English.", "us"), - new DetectLanguageInput("2", "Este es un document escrito en Español.", "es") + new DetectLanguageInput("1", "This is written in English.", "US"), + new DetectLanguageInput("2", "Este es un document escrito en Español.", "ES") ); // Request options: show statistics and model version From d4918160ab6116dd217ff63d8faf6bbee7569071 Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Mon, 6 Jan 2020 15:48:27 -0800 Subject: [PATCH 3/9] make snippets shorter --- .../checkstyle/checkstyle-suppressions.xml | 1 - ...alyticsAsyncClientJavaDocCodeSnippets.java | 116 ++++-------------- 2 files changed, 27 insertions(+), 90 deletions(-) diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index 437b118c9692f..1ba2a50abc9d1 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -266,7 +266,6 @@ - diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index 0b787bf935f03..625de2a2cff6e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -87,7 +87,7 @@ public void detectLanguageCodeSnippets() { final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," + " transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), + batchStatistics.getTransactionCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -111,16 +111,13 @@ public void detectLanguageCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { - System.out.printf("Another detected language: %s, ISO 6391 name: %s, score: %s.%n", + System.out.printf("Other detected language: %s, ISO 6391 name: %s, score: %s.%n", detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getScore()); @@ -139,16 +136,13 @@ public void detectLanguageCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { - System.out.printf("Another detected language: %s, ISO 6391 name: %s, score: %s.%n", + System.out.printf("Other detected language: %s, ISO 6391 name: %s, score: %s.%n", detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getScore()); @@ -173,10 +167,7 @@ public void detectLanguageCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," - + " transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -239,9 +230,7 @@ public void recognizeEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -268,10 +257,7 @@ public void recognizeEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -298,10 +284,7 @@ public void recognizeEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -333,10 +316,7 @@ public void recognizeEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -401,9 +381,7 @@ public void recognizePiiEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -430,10 +408,7 @@ public void recognizePiiEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -460,10 +435,7 @@ public void recognizePiiEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -495,10 +467,7 @@ public void recognizePiiEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -559,9 +528,7 @@ public void recognizeLinkedEntitiesCodeSnippets() { // Batch statistics TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," - + " transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -586,10 +553,7 @@ public void recognizeLinkedEntitiesCodeSnippets() { // Batch statistics TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -615,10 +579,7 @@ public void recognizeLinkedEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -651,8 +612,6 @@ public void recognizeLinkedEntitiesCodeSnippets() { final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, transaction" + " count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -706,9 +665,8 @@ public void extractKeyPhrasesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," - + " transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", + batchStatistics.getTransactionCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -731,10 +689,7 @@ public void extractKeyPhrasesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -756,10 +711,7 @@ public void extractKeyPhrasesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, transaction count:" - + " %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -786,10 +738,7 @@ public void extractKeyPhrasesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, transaction" - + " count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -803,7 +752,6 @@ public void extractKeyPhrasesCodeSnippets() { } // Sentiment - /** * Code snippet for recognizing entities */ @@ -861,9 +809,8 @@ public void analyzeSentimentCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," - + " transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", + batchStatistics.getTransactionCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -896,10 +843,7 @@ public void analyzeSentimentCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, " - + "transaction count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -932,10 +876,7 @@ public void analyzeSentimentCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, transaction count:" - + " %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -973,10 +914,7 @@ public void analyzeSentimentCodeSnippets() { // Batch statistics TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, transaction" - + " count: %s, valid document count: %s.%n", - batchStatistics.getDocumentCount(), - batchStatistics.getErroneousDocumentCount(), + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); From 912a658c8e26af675d11a34faff78d835810fdc1 Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Mon, 6 Jan 2020 15:52:47 -0800 Subject: [PATCH 4/9] extra lines --- .../TextAnalyticsAsyncClientJavaDocCodeSnippets.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index 625de2a2cff6e..fd2da0ccb4023 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -45,7 +45,6 @@ public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient() { } // Languages - /** * Code snippet for detecting Language */ @@ -184,7 +183,6 @@ public void detectLanguageCodeSnippets() { } // Entity - /** * Code snippet for recognizing entities */ @@ -220,7 +218,6 @@ public void recognizeEntitiesCodeSnippets() { }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string - // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List List inputs = Arrays.asList( "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); @@ -335,7 +332,6 @@ public void recognizeEntitiesCodeSnippets() { } // Pii Entity - /** * Code snippet for recognizing entities */ @@ -486,7 +482,6 @@ public void recognizePiiEntitiesCodeSnippets() { } // Linked Entity - /** * Code snippet for recognizing entities */ @@ -628,7 +623,6 @@ public void recognizeLinkedEntitiesCodeSnippets() { } // Key Phrases - /** * Code snippet for recognizing entities */ From 690f4f215b87cfd0daee58bbb9638e198fde94b2 Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Mon, 6 Jan 2020 16:19:40 -0800 Subject: [PATCH 5/9] skip logging pii --- .../azure/ai/textanalytics/RecognizePiiEntityAsyncClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizePiiEntityAsyncClient.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizePiiEntityAsyncClient.java index 781432dbd2c9e..a521bf6cae259 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizePiiEntityAsyncClient.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizePiiEntityAsyncClient.java @@ -75,7 +75,7 @@ Mono>> recognizeBa batchInput, options == null ? null : options.getModelVersion(), options == null ? null : options.showStatistics(), context) - .doOnSubscribe(ignoredValue -> logger.info("A batch of PII entities input - {}", textInputs.toString())) + .doOnSubscribe(ignoredValue -> logger.info("Processing a batch of PII entities input")) .doOnSuccess(response -> logger.info("A batch of PII entities output - {}", response.getValue())) .doOnError(error -> logger.warning("Failed to recognize PII entities - {}", error)) .map(response -> new SimpleResponse<>(response, toPiiDocumentResultCollection(response.getValue()))); From 201698c063761925a34241bc9e366b90b20f49a1 Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Tue, 7 Jan 2020 13:37:07 -0800 Subject: [PATCH 6/9] update feedback --- ...alyticsAsyncClientJavaDocCodeSnippets.java | 154 ++++++++---------- 1 file changed, 65 insertions(+), 89 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index fd2da0ccb4023..0bf48cb8ace1b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -45,6 +45,7 @@ public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient() { } // Languages + /** * Code snippet for detecting Language */ @@ -77,22 +78,20 @@ public void detectLanguageCodeSnippets() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguageWithResponse#string-string // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List - final List inputs = Arrays.asList( + final List textInputs = Arrays.asList( "This is written in English", "Este es un document escrito en Español."); - textAnalyticsAsyncClient.detectLanguages(inputs).subscribe(detectedBatchResult -> { + textAnalyticsAsyncClient.detectLanguages(textInputs).subscribe(detectedBatchResult -> { System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s," - + " transaction count: %s, valid document count: %s.%n", - batchStatistics.getTransactionCount(), + System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { - System.out.printf("Another detected language: %s, ISO 6391 name: %s, score: %s.%n", + System.out.printf("Detected language: %s, ISO 6391 name: %s, score: %s.%n", detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getScore()); @@ -102,9 +101,9 @@ public void detectLanguageCodeSnippets() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguagesWithResponse#List-String - final List listInputs = Arrays.asList( + final List textInputs1 = Arrays.asList( "This is written in English", "Este es un document escrito en Español."); - textAnalyticsAsyncClient.detectLanguagesWithResponse(listInputs, "US").subscribe(response -> { + textAnalyticsAsyncClient.detectLanguagesWithResponse(textInputs1, "US").subscribe(response -> { DocumentResultCollection detectedBatchResult = response.getValue(); System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); @@ -116,7 +115,7 @@ public void detectLanguageCodeSnippets() { for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { - System.out.printf("Other detected language: %s, ISO 6391 name: %s, score: %s.%n", + System.out.printf("Detected language: %s, ISO 6391 name: %s, score: %s.%n", detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getScore()); @@ -128,7 +127,7 @@ public void detectLanguageCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List List detectLanguageInputs = Arrays.asList( new DetectLanguageInput("1", "This is written in English.", "US"), - new DetectLanguageInput("2", "Este es un document escrito en Español.", "es") + new DetectLanguageInput("2", "Este es un document escrito en Español.", "ES") ); textAnalyticsAsyncClient.detectBatchLanguages(detectLanguageInputs).subscribe(detectedBatchResult -> { System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); @@ -141,7 +140,7 @@ public void detectLanguageCodeSnippets() { for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { - System.out.printf("Other detected language: %s, ISO 6391 name: %s, score: %s.%n", + System.out.printf("Detected language: %s, ISO 6391 name: %s, score: %s.%n", detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getScore()); @@ -172,7 +171,7 @@ public void detectLanguageCodeSnippets() { for (DetectLanguageResult detectLanguageResult : detectedBatchResult) { for (DetectedLanguage detectedLanguage : detectLanguageResult.getDetectedLanguages()) { - System.out.printf("Other detected language: %s, ISO 6391 name: %s, score: %s.%n", + System.out.printf("Detected language: %s, ISO 6391 name: %s, score: %s.%n", detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getScore()); @@ -194,10 +193,9 @@ public void recognizeEntitiesCodeSnippets() { textAnalyticsAsyncClient.recognizeEntities(inputText).subscribe(recognizeEntitiesResult -> { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } }); @@ -209,20 +207,19 @@ public void recognizeEntitiesCodeSnippets() { .subscribe(recognizeEntitiesResult -> { for (NamedEntity entity : recognizeEntitiesResult.getValue().getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List - List inputs = Arrays.asList( + List textInputs = Arrays.asList( "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); - textAnalyticsAsyncClient.recognizeEntities(inputs).subscribe(recognizeEntitiesResults -> { + textAnalyticsAsyncClient.recognizeEntities(textInputs).subscribe(recognizeEntitiesResults -> { System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics @@ -234,10 +231,9 @@ public void recognizeEntitiesCodeSnippets() { for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -245,10 +241,10 @@ public void recognizeEntitiesCodeSnippets() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#List-String - List inputs1 = Arrays.asList( + List textInputs1 = Arrays.asList( "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); - textAnalyticsAsyncClient.recognizeEntitiesWithResponse(inputs1, "en").subscribe(response -> { + textAnalyticsAsyncClient.recognizeEntitiesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection recognizeEntitiesResults = response.getValue(); System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); @@ -261,10 +257,9 @@ public void recognizeEntitiesCodeSnippets() { for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -288,10 +283,9 @@ public void recognizeEntitiesCodeSnippets() { for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -320,10 +314,9 @@ public void recognizeEntitiesCodeSnippets() { for (RecognizeEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -333,7 +326,7 @@ public void recognizeEntitiesCodeSnippets() { // Pii Entity /** - * Code snippet for recognizing entities + * Code snippet for recognizing pii entities */ public void recognizePiiEntitiesCodeSnippets() { TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); @@ -343,10 +336,9 @@ public void recognizePiiEntitiesCodeSnippets() { textAnalyticsAsyncClient.recognizePiiEntities(inputText).subscribe(recognizeEntitiesResult -> { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } }); @@ -358,10 +350,9 @@ public void recognizePiiEntitiesCodeSnippets() { .subscribe(recognizeEntitiesResult -> { for (NamedEntity entity : recognizeEntitiesResult.getValue().getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } }); @@ -369,10 +360,10 @@ public void recognizePiiEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string - List inputs = Arrays.asList( - "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + List textInputs = Arrays.asList( + "My SSN is 555-55-5555.", "Visa card 0111 1111 1111 1111."); - textAnalyticsAsyncClient.recognizePiiEntities(inputs).subscribe(recognizeEntitiesResults -> { + textAnalyticsAsyncClient.recognizePiiEntities(textInputs).subscribe(recognizeEntitiesResults -> { System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics @@ -384,10 +375,9 @@ public void recognizePiiEntitiesCodeSnippets() { for (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -395,10 +385,10 @@ public void recognizePiiEntitiesCodeSnippets() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String - List inputs1 = Arrays.asList( - "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + List textInputs1 = Arrays.asList( + "My SSN is 555-55-5555.", "Visa card 0111 1111 1111 1111."); - textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(inputs1, "en").subscribe(response -> { + textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection recognizeEntitiesResults = response.getValue(); System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); @@ -411,10 +401,9 @@ public void recognizePiiEntitiesCodeSnippets() { for (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -423,8 +412,8 @@ public void recognizePiiEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List List textDocumentInputs = Arrays.asList( - new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), - new TextDocumentInput("1", "I work at Microsoft.")); + new TextDocumentInput("0", "My SSN is 555-55-5555."), + new TextDocumentInput("1", "Visa card 0111 1111 1111 1111.")); textAnalyticsAsyncClient.recognizeBatchPiiEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); @@ -438,10 +427,9 @@ public void recognizePiiEntitiesCodeSnippets() { for (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -450,8 +438,8 @@ public void recognizePiiEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( - new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), - new TextDocumentInput("1", "I work at Microsoft.")); + new TextDocumentInput("0", "My SSN is 555-55-5555."), + new TextDocumentInput("1", "Visa card 0111 1111 1111 1111.")); // Request options: show statistics and model version final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); @@ -470,10 +458,9 @@ public void recognizePiiEntitiesCodeSnippets() { for (RecognizePiiEntitiesResult recognizeEntitiesResult : recognizeEntitiesResults) { for (NamedEntity entity : recognizeEntitiesResult.getNamedEntities()) { System.out.printf( - "Recognized Named Entity: %s, Type: %s, Subtype: %s, Score: %s.%n", + "Recognized Named Entity: %s, Type: %s, Score: %s.%n", entity.getText(), entity.getType(), - entity.getSubtype(), entity.getScore()); } } @@ -515,10 +502,10 @@ public void recognizeLinkedEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string - List inputs = Arrays.asList( - "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + List textInputs = Arrays.asList( + "Old Faithful is a geyser at Yellowstone Park.", "Mount Shasta has lenticular clouds."); - textAnalyticsAsyncClient.recognizeLinkedEntities(inputs).subscribe(recognizeLinkedEntitiesResults -> { + textAnalyticsAsyncClient.recognizeLinkedEntities(textInputs).subscribe(recognizeLinkedEntitiesResults -> { System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); // Batch statistics @@ -539,10 +526,10 @@ public void recognizeLinkedEntitiesCodeSnippets() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#List-String - List inputs1 = Arrays.asList( - "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); + List textInputs1 = Arrays.asList( + "Old Faithful is a geyser at Yellowstone Park.", "Mount Shasta has lenticular clouds."); - textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(inputs1, "en").subscribe(response -> { + textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection recognizeLinkedEntitiesResults = response.getValue(); System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); @@ -565,8 +552,8 @@ public void recognizeLinkedEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntities#List List textDocumentInputs = Arrays.asList( - new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), - new TextDocumentInput("1", "I work at Microsoft.")); + new TextDocumentInput("0", "Old Faithful is a geyser at Yellowstone Park."), + new TextDocumentInput("1", "Mount Shasta has lenticular clouds.")); textAnalyticsAsyncClient.recognizeBatchLinkedEntities(textDocumentInputs) .subscribe(recognizeLinkedEntitiesResults -> { @@ -591,8 +578,8 @@ public void recognizeLinkedEntitiesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntitiesWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( - new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), - new TextDocumentInput("1", "I work at Microsoft.")); + new TextDocumentInput("0", "Old Faithful is a geyser at Yellowstone Park."), + new TextDocumentInput("1", "Mount Shasta has lenticular clouds.")); // Request options: show statistics and model version final TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setShowStatistics(true); @@ -605,8 +592,7 @@ public void recognizeLinkedEntitiesCodeSnippets() { // Batch statistics final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); - System.out.printf("Batch statistics, document count: %s, erroneous document count: %s, transaction" - + " count: %s, valid document count: %s.%n", + System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -650,17 +636,16 @@ public void extractKeyPhrasesCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string - List inputs = Arrays.asList( + List textInputs = Arrays.asList( "Hello world. This is some input text that I love.", "Bonjour tout le monde"); - textAnalyticsAsyncClient.extractKeyPhrases(inputs).subscribe(extractKeyPhraseResults -> { + textAnalyticsAsyncClient.extractKeyPhrases(textInputs).subscribe(extractKeyPhraseResults -> { System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); // Batch statistics final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", - batchStatistics.getTransactionCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -673,11 +658,11 @@ public void extractKeyPhrasesCodeSnippets() { // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#List-String - List inputs1 = Arrays.asList( + List textInputs1 = Arrays.asList( "Hello world. This is some input text that I love.", "Bonjour tout le monde"); - textAnalyticsAsyncClient.extractKeyPhrasesWithResponse(inputs1, "en").subscribe(response -> { + textAnalyticsAsyncClient.extractKeyPhrasesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection extractKeyPhraseResults = response.getValue(); System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); @@ -795,16 +780,15 @@ public void analyzeSentimentCodeSnippets() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string - List inputs = Arrays.asList( + List textInputs = Arrays.asList( "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); - textAnalyticsAsyncClient.analyzeSentiment(inputs).subscribe(analyzeSentimentResults -> { + textAnalyticsAsyncClient.analyzeSentiment(textInputs).subscribe(analyzeSentimentResults -> { System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); // Batch statistics final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", - batchStatistics.getTransactionCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -815,23 +799,21 @@ public void analyzeSentimentCodeSnippets() { documentSentiment.getTextSentimentClass()); for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " - + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + + "negative score: %s.%n", sentenceSentiment.getTextSentimentClass(), sentenceSentiment.getPositiveScore(), sentenceSentiment.getNeutralScore(), - sentenceSentiment.getNegativeScore(), - sentenceSentiment.getLength(), - sentenceSentiment.getOffset()); + sentenceSentiment.getNegativeScore()); } } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#List-String - List inputs1 = Arrays.asList( + List textInputs1 = Arrays.asList( "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); - textAnalyticsAsyncClient.analyzeSentimentWithResponse(inputs1, "en").subscribe(response -> { + textAnalyticsAsyncClient.analyzeSentimentWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection analyzeSentimentResults = response.getValue(); System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); @@ -848,13 +830,11 @@ public void analyzeSentimentCodeSnippets() { documentSentiment.getTextSentimentClass()); for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " - + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + + "negative score: %s.%n", sentenceSentiment.getTextSentimentClass(), sentenceSentiment.getPositiveScore(), sentenceSentiment.getNeutralScore(), - sentenceSentiment.getNegativeScore(), - sentenceSentiment.getLength(), - sentenceSentiment.getOffset()); + sentenceSentiment.getNegativeScore()); } } }); @@ -881,13 +861,11 @@ public void analyzeSentimentCodeSnippets() { documentSentiment.getTextSentimentClass()); for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " - + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + + "negative score: %s.%n", sentenceSentiment.getTextSentimentClass(), sentenceSentiment.getPositiveScore(), sentenceSentiment.getNeutralScore(), - sentenceSentiment.getNegativeScore(), - sentenceSentiment.getLength(), - sentenceSentiment.getOffset()); + sentenceSentiment.getNegativeScore()); } } }); @@ -919,13 +897,11 @@ public void analyzeSentimentCodeSnippets() { documentSentiment.getTextSentimentClass()); for (TextSentiment sentenceSentiment : analyzeSentimentResult.getSentenceSentiments()) { System.out.printf("Recognized sentence sentiment: %s, positive score: %s, neutral score: %s, " - + "negative score: %s, length of sentence: %s, offset of sentence: %s.%n", + + "negative score: %s.%n", sentenceSentiment.getTextSentimentClass(), sentenceSentiment.getPositiveScore(), sentenceSentiment.getNeutralScore(), - sentenceSentiment.getNegativeScore(), - sentenceSentiment.getLength(), - sentenceSentiment.getOffset()); + sentenceSentiment.getNegativeScore()); } } }); From a96ca2e759c87f870c0401bcc10b331cbc7f6cef Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Tue, 7 Jan 2020 16:00:45 -0800 Subject: [PATCH 7/9] refactor methods to seperate snippets --- ...alyticsAsyncClientJavaDocCodeSnippets.java | 199 +++++++++++++++--- 1 file changed, 173 insertions(+), 26 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index 0bf48cb8ace1b..8917d939537d4 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -28,6 +28,7 @@ public class TextAnalyticsAsyncClientJavaDocCodeSnippets { private static final String SUBSCRIPTION_KEY = null; private static final String ENDPOINT = null; + TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); /** * Code snippet for creating a {@link TextAnalyticsAsyncClient} @@ -45,13 +46,10 @@ public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient() { } // Languages - /** - * Code snippet for detecting Language + * Code snippet for {@link TextAnalyticsAsyncClient#detectLanguage(String)} */ - public void detectLanguageCodeSnippets() { - TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); - + public void detectLanguages() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguage#string String inputText = "Bonjour tout le monde"; textAnalyticsAsyncClient.detectLanguage(inputText).subscribe(detectLanguageResult -> { @@ -63,7 +61,12 @@ public void detectLanguageCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguage#string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#detectLanguageWithResponse(String, String)} + */ + public void detectLanguageWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguageWithResponse#string-string String input = "This text is in English"; String countryHint = "US"; @@ -76,7 +79,12 @@ public void detectLanguageCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguageWithResponse#string-string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#detectLanguages(List)} + */ + public void detectLanguagesStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List final List textInputs = Arrays.asList( "This is written in English", "Este es un document escrito en Español."); @@ -99,7 +107,12 @@ public void detectLanguageCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguages#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#detectLanguagesWithResponse(List, String)} + */ + public void detectLanguagesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguagesWithResponse#List-String final List textInputs1 = Arrays.asList( "This is written in English", "Este es un document escrito en Español."); @@ -123,7 +136,12 @@ public void detectLanguageCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectLanguagesWithResponse#List-String + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#detectBatchLanguages(List)} )} + */ + public void detectLanguagesBatch() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List List detectLanguageInputs = Arrays.asList( new DetectLanguageInput("1", "This is written in English.", "US"), @@ -148,7 +166,13 @@ public void detectLanguageCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguages#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#detectBatchLanguagesWithResponse(List, + * TextAnalyticsRequestOptions)} + */ + public void detectBatchLanguagesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.detectBatchLanguagesWithResponse#List-TextAnalyticsRequestOptions List detectLanguageInputs1 = Arrays.asList( new DetectLanguageInput("1", "This is written in English.", "US"), @@ -183,11 +207,9 @@ public void detectLanguageCodeSnippets() { // Entity /** - * Code snippet for recognizing entities + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeEntities(String)} */ - public void recognizeEntitiesCodeSnippets() { - TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); - + public void recognizeEntities() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#string String inputText = "Satya Nadella is the CEO of Microsoft"; textAnalyticsAsyncClient.recognizeEntities(inputText).subscribe(recognizeEntitiesResult -> { @@ -200,7 +222,12 @@ public void recognizeEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeEntitiesWithResponse(String, String)} + */ + public void recognizeEntitiesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string String inputText1 = "Satya Nadella is the CEO of Microsoft"; textAnalyticsAsyncClient.recognizeEntitiesWithResponse(inputText1, "en") @@ -214,7 +241,12 @@ public void recognizeEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#string-string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeEntities(List)} + */ + public void recognizeEntitiesStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List List textInputs = Arrays.asList( "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); @@ -239,7 +271,12 @@ public void recognizeEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntities#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeEntitiesWithResponse(List, String)} + */ + public void recognizeEntitiesWithResponseStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#List-String List textInputs1 = Arrays.asList( "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); @@ -265,7 +302,12 @@ public void recognizeEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeEntitiesWithResponse#List-String + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeBatchEntities(List)} + */ + public void recognizeBatchEntities() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List List textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), @@ -291,7 +333,13 @@ public void recognizeEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntities#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeBatchEntitiesWithResponse(List, + * TextAnalyticsRequestOptions)} + */ + public void recognizeBatchEntitiesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchEntitiesWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), @@ -326,10 +374,9 @@ public void recognizeEntitiesCodeSnippets() { // Pii Entity /** - * Code snippet for recognizing pii entities + * Code snippet for {@link TextAnalyticsAsyncClient#recognizePiiEntities(String)} */ - public void recognizePiiEntitiesCodeSnippets() { - TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + public void recognizePiiEntities() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#string String inputText = "My SSN is 555-55-5555"; @@ -343,6 +390,12 @@ public void recognizePiiEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#string + } + + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizePiiEntitiesWithResponse(String, String)} + */ + public void recognizePiiEntitiesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string String inputText1 = "My SSN is 555-55-5555"; @@ -357,8 +410,12 @@ public void recognizePiiEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string + } - + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizePiiEntities(List)} + */ + public void recognizePiiEntitiesStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string List textInputs = Arrays.asList( "My SSN is 555-55-5555.", "Visa card 0111 1111 1111 1111."); @@ -383,7 +440,12 @@ public void recognizePiiEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizePiiEntitiesWithResponse(List, String)} + */ + public void recognizePiiEntitiesWithResponseStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String List textInputs1 = Arrays.asList( "My SSN is 555-55-5555.", "Visa card 0111 1111 1111 1111."); @@ -409,7 +471,12 @@ public void recognizePiiEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeBatchPiiEntities(List)} + */ + public void recognizeBatchPiiEntities() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List List textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "My SSN is 555-55-5555."), @@ -435,7 +502,13 @@ public void recognizePiiEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeBatchPiiEntitiesWithResponse(List, + * TextAnalyticsRequestOptions)} + */ + public void recognizeBatchPiiEntitiesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( new TextDocumentInput("0", "My SSN is 555-55-5555."), @@ -470,10 +543,9 @@ public void recognizePiiEntitiesCodeSnippets() { // Linked Entity /** - * Code snippet for recognizing entities + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeLinkedEntities(String)} */ - public void recognizeLinkedEntitiesCodeSnippets() { - TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); + public void recognizeLinkedEntities() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#string String inputText = "Old Faithful is a geyser at Yellowstone Park."; @@ -486,6 +558,12 @@ public void recognizeLinkedEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#string + } + + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeLinkedEntitiesWithResponse(String, String)} + */ + public void recognizeLinkedEntitiesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#string-string String inputText1 = "Old Faithful is a geyser at Yellowstone Park."; @@ -499,7 +577,12 @@ public void recognizeLinkedEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#string-string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeLinkedEntities(List)} + */ + public void recognizeLinkedEntitiesStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string List textInputs = Arrays.asList( @@ -524,6 +607,12 @@ public void recognizeLinkedEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntities#list-string + } + + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeLinkedEntitiesWithResponse(List, String)} + */ + public void recognizeLinkedEntitiesWithResponseStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#List-String List textInputs1 = Arrays.asList( @@ -550,6 +639,12 @@ public void recognizeLinkedEntitiesCodeSnippets() { }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse#List-String + } + + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeBatchLinkedEntities(List)} + */ + public void recognizeBatchLinkedEntities() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntities#List List textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "Old Faithful is a geyser at Yellowstone Park."), @@ -575,7 +670,13 @@ public void recognizeLinkedEntitiesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntities#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#recognizeBatchLinkedEntitiesWithResponse(List, + * TextAnalyticsRequestOptions)} + */ + public void recognizeBatchLinkedEntitiesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchLinkedEntitiesWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( new TextDocumentInput("0", "Old Faithful is a geyser at Yellowstone Park."), @@ -610,11 +711,9 @@ public void recognizeLinkedEntitiesCodeSnippets() { // Key Phrases /** - * Code snippet for recognizing entities + * Code snippet for {@link TextAnalyticsAsyncClient#extractKeyPhrases(String)} */ - public void extractKeyPhrasesCodeSnippets() { - TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); - + public void extractKeyPhrases() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#string String inputText = "Bonjour tout le monde"; textAnalyticsAsyncClient.extractKeyPhrases(inputText).subscribe(extractKeyPhraseResult -> { @@ -623,7 +722,12 @@ public void extractKeyPhrasesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#extractKeyPhrasesWithResponse(String, String)} + */ + public void extractKeyPhrasesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#string-string String inputText1 = "Bonjour tout le monde"; textAnalyticsAsyncClient.extractKeyPhrasesWithResponse(inputText1, "fr") @@ -633,8 +737,12 @@ public void extractKeyPhrasesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#string-string + } - + /** + * Code snippet for {@link TextAnalyticsAsyncClient#extractKeyPhrases(List)} + */ + public void extractKeyPhrasesStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string List textInputs = Arrays.asList( "Hello world. This is some input text that I love.", @@ -656,7 +764,12 @@ public void extractKeyPhrasesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrases#list-string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#extractKeyPhrasesWithResponse(List, String)} + */ + public void extractKeyPhrasesWithResponseStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#List-String List textInputs1 = Arrays.asList( "Hello world. This is some input text that I love.", @@ -679,7 +792,12 @@ public void extractKeyPhrasesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesWithResponse#List-String + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#extractBatchKeyPhrases(List)} + */ + public void extractBatchKeyPhrases() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrases#List List textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "Hello world. This is some input text that I love."), @@ -701,7 +819,13 @@ public void extractKeyPhrasesCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrases#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#extractBatchKeyPhrasesWithResponse(List, + * TextAnalyticsRequestOptions)} + */ + public void extractBatchKeyPhrasesWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractBatchKeyPhrasesWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."), @@ -732,11 +856,9 @@ public void extractKeyPhrasesCodeSnippets() { // Sentiment /** - * Code snippet for recognizing entities + * Code snippet for {@link TextAnalyticsAsyncClient#analyzeSentiment(String)} */ - public void analyzeSentimentCodeSnippets() { - TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient(); - + public void analyzeSentiment() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#string String inputText = "The hotel was dark and unclean."; textAnalyticsAsyncClient.analyzeSentiment(inputText).subscribe(analyzeSentimentResult -> { @@ -755,7 +877,12 @@ public void analyzeSentimentCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#analyzeSentimentWithResponse(String, String)} + */ + public void analyzeSentimentWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#string-string String inputText1 = "The hotel was dark and unclean."; textAnalyticsAsyncClient.analyzeSentimentWithResponse(inputText1, "en") @@ -777,8 +904,12 @@ public void analyzeSentimentCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#string-string + } - + /** + * Code snippet for {@link TextAnalyticsAsyncClient#analyzeSentiment(List)} + */ + public void analyzeSentimentStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string List textInputs = Arrays.asList( "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); @@ -808,7 +939,12 @@ public void analyzeSentimentCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentiment#list-string + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#analyzeSentimentWithResponse(List, String)} + */ + public void analyzeSentimentWithResponseStringList() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#List-String List textInputs1 = Arrays.asList( "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); @@ -839,7 +975,12 @@ public void analyzeSentimentCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentWithResponse#List-String + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#analyzeBatchSentiment(List)} + */ + public void analyzeBatchSentiment() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentiment#List List textDocumentInputs = Arrays.asList( new TextDocumentInput("0", "The hotel was dark and unclean."), @@ -870,7 +1011,13 @@ public void analyzeSentimentCodeSnippets() { } }); // END: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentiment#List + } + /** + * Code snippet for {@link TextAnalyticsAsyncClient#analyzeBatchSentimentWithResponse(List, + * TextAnalyticsRequestOptions)} + */ + public void analyzeBatchSentimentWithResponse() { // BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeBatchSentimentWithResponse#List-TextAnalyticsRequestOptions List textDocumentInputs1 = Arrays.asList( new TextDocumentInput("0", "The hotel was dark and unclean."), From 8b62a177204d968e603be30d88980fdf36fd34a4 Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Tue, 7 Jan 2020 16:11:00 -0800 Subject: [PATCH 8/9] remove model versions sysout --- ...alyticsAsyncClientJavaDocCodeSnippets.java | 66 ++++++------------- 1 file changed, 20 insertions(+), 46 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java index 8917d939537d4..7a13f73091ac1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientJavaDocCodeSnippets.java @@ -89,8 +89,6 @@ public void detectLanguagesStringList() { final List textInputs = Arrays.asList( "This is written in English", "Este es un document escrito en Español."); textAnalyticsAsyncClient.detectLanguages(textInputs).subscribe(detectedBatchResult -> { - System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); - // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", @@ -118,7 +116,6 @@ public void detectLanguagesWithResponse() { "This is written in English", "Este es un document escrito en Español."); textAnalyticsAsyncClient.detectLanguagesWithResponse(textInputs1, "US").subscribe(response -> { DocumentResultCollection detectedBatchResult = response.getValue(); - System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); @@ -148,7 +145,6 @@ public void detectLanguagesBatch() { new DetectLanguageInput("2", "Este es un document escrito en Español.", "ES") ); textAnalyticsAsyncClient.detectBatchLanguages(detectLanguageInputs).subscribe(detectedBatchResult -> { - System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); // Batch statistics final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); @@ -184,11 +180,10 @@ public void detectBatchLanguagesWithResponse() { textAnalyticsAsyncClient.detectBatchLanguagesWithResponse(detectLanguageInputs1, requestOptions) .subscribe(response -> { - final DocumentResultCollection detectedBatchResult = response.getValue(); - System.out.printf("Model version: %s%n", detectedBatchResult.getModelVersion()); + DocumentResultCollection detectedBatchResult = response.getValue(); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); + TextDocumentBatchStatistics batchStatistics = detectedBatchResult.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -252,10 +247,8 @@ public void recognizeEntitiesStringList() { "I had a wonderful trip to Seattle last week.", "I work at Microsoft."); textAnalyticsAsyncClient.recognizeEntities(textInputs).subscribe(recognizeEntitiesResults -> { - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); - // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -283,10 +276,9 @@ public void recognizeEntitiesWithResponseStringList() { textAnalyticsAsyncClient.recognizeEntitiesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection recognizeEntitiesResults = response.getValue(); - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -314,10 +306,9 @@ public void recognizeBatchEntities() { new TextDocumentInput("1", "I work at Microsoft.")); textAnalyticsAsyncClient.recognizeBatchEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -350,11 +341,10 @@ public void recognizeBatchEntitiesWithResponse() { textAnalyticsAsyncClient.recognizeBatchEntitiesWithResponse(textDocumentInputs1, requestOptions) .subscribe(response -> { - final DocumentResultCollection recognizeEntitiesResults = response.getValue(); - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); + DocumentResultCollection recognizeEntitiesResults = response.getValue(); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -421,10 +411,9 @@ public void recognizePiiEntitiesStringList() { "My SSN is 555-55-5555.", "Visa card 0111 1111 1111 1111."); textAnalyticsAsyncClient.recognizePiiEntities(textInputs).subscribe(recognizeEntitiesResults -> { - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -452,10 +441,9 @@ public void recognizePiiEntitiesWithResponseStringList() { textAnalyticsAsyncClient.recognizePiiEntitiesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection recognizeEntitiesResults = response.getValue(); - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -483,10 +471,9 @@ public void recognizeBatchPiiEntities() { new TextDocumentInput("1", "Visa card 0111 1111 1111 1111.")); textAnalyticsAsyncClient.recognizeBatchPiiEntities(textDocumentInputs).subscribe(recognizeEntitiesResults -> { - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -520,10 +507,9 @@ public void recognizeBatchPiiEntitiesWithResponse() { textAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse(textDocumentInputs1, requestOptions) .subscribe(response -> { DocumentResultCollection recognizeEntitiesResults = response.getValue(); - System.out.printf("Model version: %s%n", recognizeEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeEntitiesResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -589,7 +575,6 @@ public void recognizeLinkedEntitiesStringList() { "Old Faithful is a geyser at Yellowstone Park.", "Mount Shasta has lenticular clouds."); textAnalyticsAsyncClient.recognizeLinkedEntities(textInputs).subscribe(recognizeLinkedEntitiesResults -> { - System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); // Batch statistics TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); @@ -620,7 +605,6 @@ public void recognizeLinkedEntitiesWithResponseStringList() { textAnalyticsAsyncClient.recognizeLinkedEntitiesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection recognizeLinkedEntitiesResults = response.getValue(); - System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); // Batch statistics TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); @@ -652,10 +636,9 @@ public void recognizeBatchLinkedEntities() { textAnalyticsAsyncClient.recognizeBatchLinkedEntities(textDocumentInputs) .subscribe(recognizeLinkedEntitiesResults -> { - System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -689,10 +672,9 @@ public void recognizeBatchLinkedEntitiesWithResponse() { .subscribe(response -> { DocumentResultCollection recognizeLinkedEntitiesResults = response.getValue(); - System.out.printf("Model version: %s%n", recognizeLinkedEntitiesResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = recognizeLinkedEntitiesResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -749,10 +731,9 @@ public void extractKeyPhrasesStringList() { "Bonjour tout le monde"); textAnalyticsAsyncClient.extractKeyPhrases(textInputs).subscribe(extractKeyPhraseResults -> { - System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -777,10 +758,9 @@ public void extractKeyPhrasesWithResponseStringList() { textAnalyticsAsyncClient.extractKeyPhrasesWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection extractKeyPhraseResults = response.getValue(); - System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -804,10 +784,9 @@ public void extractBatchKeyPhrases() { new TextDocumentInput("1", "I work at Microsoft.")); textAnalyticsAsyncClient.extractBatchKeyPhrases(textDocumentInputs).subscribe(extractKeyPhraseResults -> { - System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -837,10 +816,9 @@ public void extractBatchKeyPhrasesWithResponse() { textAnalyticsAsyncClient.extractBatchKeyPhrasesWithResponse(textDocumentInputs1, requestOptions) .subscribe(response -> { final DocumentResultCollection extractKeyPhraseResults = response.getValue(); - System.out.printf("Model version: %s%n", extractKeyPhraseResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = extractKeyPhraseResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -915,10 +893,9 @@ public void analyzeSentimentStringList() { "The hotel was dark and unclean.", "The restaurant had amazing gnocchi."); textAnalyticsAsyncClient.analyzeSentiment(textInputs).subscribe(analyzeSentimentResults -> { - System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -951,10 +928,9 @@ public void analyzeSentimentWithResponseStringList() { textAnalyticsAsyncClient.analyzeSentimentWithResponse(textInputs1, "en").subscribe(response -> { DocumentResultCollection analyzeSentimentResults = response.getValue(); - System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); System.out.printf("Batch statistics,transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -987,10 +963,9 @@ public void analyzeBatchSentiment() { new TextDocumentInput("1", "The restaurant had amazing gnocchi.")); textAnalyticsAsyncClient.analyzeBatchSentiment(textDocumentInputs).subscribe(analyzeSentimentResults -> { - System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); // Batch statistics - final TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); + TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); System.out.printf("Batch statistics, transaction count: %s, valid document count: %s.%n", batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount()); @@ -1029,7 +1004,6 @@ public void analyzeBatchSentimentWithResponse() { textAnalyticsAsyncClient.analyzeBatchSentimentWithResponse(textDocumentInputs1, requestOptions) .subscribe(response -> { DocumentResultCollection analyzeSentimentResults = response.getValue(); - System.out.printf("Model version: %s%n", analyzeSentimentResults.getModelVersion()); // Batch statistics TextDocumentBatchStatistics batchStatistics = analyzeSentimentResults.getStatistics(); From df5faab563a34fd4be2303ead02f19bd0f5056ce Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Tue, 7 Jan 2020 17:00:11 -0800 Subject: [PATCH 9/9] pii -> PII --- .../ai/textanalytics/TextAnalyticsAsyncClient.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java index 6552625c63785..297031f348647 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClient.java @@ -441,7 +441,7 @@ public Mono>> recogni * supported entity types, check . See * for the list of enabled languages. * - *

Recognize pii entities in a text. Subscribes to the call asynchronously and prints out the + *

Recognize PII entities in a text. Subscribes to the call asynchronously and prints out the * entity details when a response is received.

* * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#string} @@ -466,7 +466,7 @@ public Mono recognizePiiEntities(String text) { * supported entity types, check: . For a list of enabled languages, * check: . * - *

Recognize pii entities in a text with provided language hint. Subscribes to the call asynchronously and + *

Recognize PII entities in a text with provided language hint. Subscribes to the call asynchronously and * prints out the entity details when a response is received.

* * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#string-string} @@ -495,7 +495,7 @@ public Mono> recognizePiiEntitiesWithRespon * of supported entity types, check: . For a list of enabled languages, * check: for the list of enabled languages. * - *

Recognize pii entities in a list of string inputs. Subscribes to the call asynchronously and prints out the + *

Recognize PII entities in a list of string inputs. Subscribes to the call asynchronously and prints out the * entity details when a response is received.

* * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntities#list-string} @@ -522,7 +522,7 @@ public Mono> recognizePiiEn * of supported entity types, check . For a list of enabled languages, * check: . * - *

Recognize pii entities in a list of string inputs with provided language hint. Subscribes to the call + *

Recognize PII entities in a list of string inputs with provided language hint. Subscribes to the call * asynchronously and prints out the entity details when a response is received.

* * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizePiiEntitiesWithResponse#List-String} @@ -552,7 +552,7 @@ public Mono>> reco * the list of supported entity types, check: * For a list of enabled languages, check: . * - *

Recognize pii entities in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out + *

Recognize PII entities in a list of TextDocumentInput. Subscribes to the call asynchronously and prints out * the entity details when a response is received.

* * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntities#List} @@ -579,7 +579,7 @@ public Mono> recognizeBatch * the list of supported entity types,check: . For a list of enabled languages, * check: . * - *

Recognize pii entities in a list of TextDocumentInput with provided statistics options. Subscribes to the + *

Recognize PII entities in a list of TextDocumentInput with provided statistics options. Subscribes to the * call asynchronously and prints out the entity details when a response is received.

* * {@codesnippet com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeBatchPiiEntitiesWithResponse#List-TextAnalyticsRequestOptions}