Skip to content

Commit da82993

Browse files
authored
Merge pull request #110909 from thediris/textanalytics_java_quickstart_1.0.4
Update Java quickstart to 1.0.0-beta.4
2 parents a5d9990 + ed7b83e commit da82993

File tree

1 file changed

+5
-33
lines changed
  • articles/cognitive-services/text-analytics/includes/quickstarts

1 file changed

+5
-33
lines changed

articles/cognitive-services/text-analytics/includes/quickstarts/java-sdk.md

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.reviewer: tasharm, assafi, sumeh
1313

1414
<a name="HOLTop"></a>
1515

16-
[Reference documentation](https://aka.ms/azsdk-java-textanalytics-ref-docs) | [Library source code](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/textanalytics/azure-ai-textanalytics) | [Package](https://mvnrepository.com/artifact/com.azure/azure-ai-textanalytics/1.0.0-beta.3) | [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics)
16+
[Reference documentation](https://aka.ms/azsdk-java-textanalytics-ref-docs) | [Library source code](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/textanalytics/azure-ai-textanalytics) | [Package](https://mvnrepository.com/artifact/com.azure/azure-ai-textanalytics/1.0.0-beta.4) | [Samples](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/textanalytics/azure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics)
1717

1818
## Prerequisites
1919

@@ -27,14 +27,14 @@ ms.reviewer: tasharm, assafi, sumeh
2727

2828
### Add the client library
2929

30-
Create a Maven project in your preferred IDE or development environment. Then add the following dependency to your project's *pom.xml* file. You can find the implementation syntax [for other build tools](https://mvnrepository.com/artifact/com.azure/azure-ai-textanalytics/1.0.0-beta.3) online.
30+
Create a Maven project in your preferred IDE or development environment. Then add the following dependency to your project's *pom.xml* file. You can find the implementation syntax [for other build tools](https://mvnrepository.com/artifact/com.azure/azure-ai-textanalytics/1.0.0-beta.4) online.
3131

3232
```xml
3333
<dependencies>
3434
<dependency>
3535
<groupId>com.azure</groupId>
3636
<artifactId>azure-ai-textanalytics</artifactId>
37-
<version>1.0.0-beta.3</version>
37+
<version>1.0.0-beta.4</version>
3838
</dependency>
3939
</dependencies>
4040
```
@@ -45,6 +45,7 @@ Create a Maven project in your preferred IDE or development environment. Then ad
4545
Create a Java file named `TextAnalyticsSamples.java`. Open the file and add the following `import` statements:
4646

4747
```java
48+
import com.azure.core.credential.AzureKeyCredential;
4849
import com.azure.ai.textanalytics.models.*;
4950
import com.azure.ai.textanalytics.TextAnalyticsClientBuilder;
5051
import com.azure.ai.textanalytics.TextAnalyticsClient;
@@ -71,7 +72,6 @@ public static void main(String[] args) {
7172
sentimentAnalysisExample(client);
7273
detectLanguageExample(client);
7374
recognizeEntitiesExample(client);
74-
recognizePIIEntitiesExample(client);
7575
recognizeLinkedEntitiesExample(client);
7676
extractKeyPhrasesExample(client);
7777
}
@@ -97,7 +97,7 @@ Create a method to instantiate the `TextAnalyticsClient` object with the key and
9797
```java
9898
static TextAnalyticsClient authenticateClient(String key, String endpoint) {
9999
return new TextAnalyticsClientBuilder()
100-
.apiKey(new TextAnalyticsApiKeyCredential(key))
100+
.apiKey(new AzureKeyCredential(key))
101101
.endpoint(endpoint)
102102
.buildClient();
103103
}
@@ -201,34 +201,6 @@ Recognized entity: Seattle, entity category: Location, entity sub-category: GPE,
201201
Recognized entity: last week, entity category: DateTime, entity sub-category: DateRange, score: 0.8.
202202
```
203203

204-
## Using NER to recognize personal information
205-
206-
Create a new function called `recognizePIIEntitiesExample()` that takes the client that you created earlier, and call its `recognizePiiEntities()` function. The returned `RecognizePiiEntitiesResult` object will contain a list of `NamedEntity` if successful, or an `errorMessage` if not.
207-
208-
```java
209-
static void recognizePIIEntitiesExample(TextAnalyticsClient client)
210-
{
211-
// The text that need be analyzed.
212-
String text = "Insurance policy for SSN on file 123-12-1234 is here by approved.";
213-
214-
for (PiiEntity entity : client.recognizePiiEntities(text)) {
215-
System.out.printf(
216-
"Recognized personal identifiable information entity: %s, entity category: %s, %nentity sub-category: %s, score: %s.%n",
217-
entity.getText(),
218-
entity.getCategory(),
219-
entity.getSubCategory(),
220-
entity.getConfidenceScore());
221-
}
222-
}
223-
```
224-
225-
### Output
226-
227-
```console
228-
Recognized personal identifiable information entity: 123-12-1234, entity category: U.S. Social Security Number (SSN),
229-
entity sub-category: null, score: 0.85.
230-
```
231-
232204
## Entity linking
233205

234206
Create a new function called `recognizeLinkedEntitiesExample()` that takes the client that you created earlier, and call its `recognizeLinkedEntities()` function. The returned `RecognizeLinkedEntitiesResult` object will contain a list of `LinkedEntity` if successful, or an `errorMessage` if not. Since linked entities are uniquely identified, occurrences of the same entity are grouped under a `LinkedEntity` object as a list of `LinkedEntityMatch` objects.

0 commit comments

Comments
 (0)