Skip to content

Commit 877939b

Browse files
committed
update Java QS for preview.5
1 parent 5ba4b12 commit 877939b

File tree

1 file changed

+56
-55
lines changed
  • articles/cognitive-services/text-analytics/includes/quickstarts

1 file changed

+56
-55
lines changed

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

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Create a Maven project in your preferred IDE or development environment. Then ad
3434
<dependency>
3535
<groupId>com.azure</groupId>
3636
<artifactId>azure-ai-textanalytics</artifactId>
37-
<version>1.0.0-beta.4</version>
37+
<version>1.0.0-beta.5</version>
3838
</dependency>
3939
</dependencies>
4040
```
@@ -96,10 +96,10 @@ Create a method to instantiate the `TextAnalyticsClient` object with the key and
9696

9797
```java
9898
static TextAnalyticsClient authenticateClient(String key, String endpoint) {
99-
return new TextAnalyticsClientBuilder()
100-
.apiKey(new AzureKeyCredential(key))
101-
.endpoint(endpoint)
102-
.buildClient();
99+
return new TextAnalyticsClientBuilder()
100+
.credential(new AzureKeyCredential(key))
101+
.endpoint(endpoint)
102+
.buildClient();
103103
}
104104
```
105105

@@ -152,14 +152,14 @@ Create a new function called `detectLanguageExample()` that takes the client tha
152152
```java
153153
static void detectLanguageExample(TextAnalyticsClient client)
154154
{
155-
// The text that need be analyzed.
156-
String text = "Ce document est rédigé en Français.";
157-
158-
DetectedLanguage detectedLanguage = client.detectLanguage(text);
159-
System.out.printf("Detected primary language: %s, ISO 6391 name: %s, score: %.2f.%n",
160-
detectedLanguage.getName(),
161-
detectedLanguage.getIso6391Name(),
162-
detectedLanguage.getScore());
155+
// The text that need be analyzed.
156+
String text = "Ce document est rédigé en Français.";
157+
158+
DetectedLanguage detectedLanguage = client.detectLanguage(text);
159+
System.out.printf("Detected primary language: %s, ISO 6391 name: %s, score: %.2f.%n",
160+
detectedLanguage.getName(),
161+
detectedLanguage.getIso6391Name(),
162+
detectedLanguage.getConfidenceScore());
163163
}
164164
```
165165

@@ -171,7 +171,7 @@ Detected primary language: French, ISO 6391 name: fr, score: 1.00.
171171
## Named Entity recognition (NER)
172172

173173
> [!NOTE]
174-
> In version `3.0-preview`:
174+
> In version `3.0`:
175175
> * NER includes separate methods for detecting personal information.
176176
> * Entity linking is a separate request than NER.
177177
@@ -180,24 +180,25 @@ Create a new function called `recognizeEntitiesExample()` that takes the client
180180
```java
181181
static void recognizeEntitiesExample(TextAnalyticsClient client)
182182
{
183-
// The text that need be analyzed.
184-
String text = "I had a wonderful trip to Seattle last week.";
185-
186-
for (CategorizedEntity entity : client.recognizeEntities(text)) {
187-
System.out.printf(
188-
"Recognized entity: %s, entity category: %s, entity sub-category: %s, score: %s.%n",
189-
entity.getText(),
190-
entity.getCategory(),
191-
entity.getSubCategory(),
192-
entity.getConfidenceScore());
193-
}
183+
// The text that need be analyzed.
184+
String text = "I had a wonderful trip to Seattle last week.";
185+
186+
for (CategorizedEntity entity : client.recognizeEntities(text)) {
187+
System.out.printf(
188+
"Recognized entity: %s, entity category: %s, entity sub-category: %s, score: %s.%n",
189+
entity.getText(),
190+
entity.getCategory(),
191+
entity.getSubcategory(),
192+
entity.getConfidenceScore());
193+
}
194194
}
195195
```
196196

197197
### Output
198198

199199
```console
200-
Recognized entity: Seattle, entity category: Location, entity sub-category: GPE, score: 0.92.
200+
Recognized entity: trip, entity category: Event, entity sub-category: null, score: 0.61.
201+
Recognized entity: Seattle, entity category: Location, entity sub-category: GPE, score: 0.82.
201202
Recognized entity: last week, entity category: DateTime, entity sub-category: DateRange, score: 0.8.
202203
```
203204

@@ -208,27 +209,27 @@ Create a new function called `recognizeLinkedEntitiesExample()` that takes the c
208209
```java
209210
static void recognizeLinkedEntitiesExample(TextAnalyticsClient client)
210211
{
211-
// The text that need be analyzed.
212-
String text = "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975, " +
213-
"to develop and sell BASIC interpreters for the Altair 8800. " +
214-
"During his career at Microsoft, Gates held the positions of chairman, " +
215-
"chief executive officer, president and chief software architect, " +
216-
"while also being the largest individual shareholder until May 2014.";
217-
218-
System.out.printf("Linked Entities:%n");
219-
for (LinkedEntity linkedEntity : client.recognizeLinkedEntities(text)) {
220-
System.out.printf("Name: %s, ID: %s, URL: %s, Data Source: %s.%n",
221-
linkedEntity.getName(),
222-
linkedEntity.getDataSourceEntityId(),
223-
linkedEntity.getUrl(),
224-
linkedEntity.getDataSource());
225-
System.out.printf("Matches:%n");
226-
for (LinkedEntityMatch linkedEntityMatch : linkedEntity.getLinkedEntityMatches()) {
227-
System.out.printf("Text: %s, Score: %.2f%n",
228-
linkedEntityMatch.getText(),
229-
linkedEntityMatch.getConfidenceScore());
230-
}
231-
}
212+
// The text that need be analyzed.
213+
String text = "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975, " +
214+
"to develop and sell BASIC interpreters for the Altair 8800. " +
215+
"During his career at Microsoft, Gates held the positions of chairman, " +
216+
"chief executive officer, president and chief software architect, " +
217+
"while also being the largest individual shareholder until May 2014.";
218+
219+
System.out.printf("Linked Entities:%n");
220+
for (LinkedEntity linkedEntity : client.recognizeLinkedEntities(text)) {
221+
System.out.printf("Name: %s, ID: %s, URL: %s, Data Source: %s.%n",
222+
linkedEntity.getName(),
223+
linkedEntity.getDataSourceEntityId(),
224+
linkedEntity.getUrl(),
225+
linkedEntity.getDataSource());
226+
System.out.printf("Matches:%n");
227+
for (LinkedEntityMatch linkedEntityMatch : linkedEntity.getMatches()) {
228+
System.out.printf("Text: %s, Score: %.2f%n",
229+
linkedEntityMatch.getText(),
230+
linkedEntityMatch.getConfidenceScore());
231+
}
232+
}
232233
}
233234
```
234235

@@ -238,24 +239,24 @@ static void recognizeLinkedEntitiesExample(TextAnalyticsClient client)
238239
Linked Entities:
239240
Name: Altair 8800, ID: Altair 8800, URL: https://en.wikipedia.org/wiki/Altair_8800, Data Source: Wikipedia.
240241
Matches:
241-
Text: Altair 8800, Score: 0.78
242+
Text: Altair 8800, Score: 0.88
242243
Name: Bill Gates, ID: Bill Gates, URL: https://en.wikipedia.org/wiki/Bill_Gates, Data Source: Wikipedia.
243244
Matches:
244-
Text: Bill Gates, Score: 0.55
245-
Text: Gates, Score: 0.55
245+
Text: Bill Gates, Score: 0.63
246+
Text: Gates, Score: 0.63
246247
Name: Paul Allen, ID: Paul Allen, URL: https://en.wikipedia.org/wiki/Paul_Allen, Data Source: Wikipedia.
247248
Matches:
248-
Text: Paul Allen, Score: 0.53
249+
Text: Paul Allen, Score: 0.60
249250
Name: Microsoft, ID: Microsoft, URL: https://en.wikipedia.org/wiki/Microsoft, Data Source: Wikipedia.
250251
Matches:
251-
Text: Microsoft, Score: 0.47
252-
Text: Microsoft, Score: 0.47
252+
Text: Microsoft, Score: 0.55
253+
Text: Microsoft, Score: 0.55
253254
Name: April 4, ID: April 4, URL: https://en.wikipedia.org/wiki/April_4, Data Source: Wikipedia.
254255
Matches:
255-
Text: April 4, Score: 0.25
256+
Text: April 4, Score: 0.32
256257
Name: BASIC, ID: BASIC, URL: https://en.wikipedia.org/wiki/BASIC, Data Source: Wikipedia.
257258
Matches:
258-
Text: BASIC, Score: 0.28
259+
Text: BASIC, Score: 0.33
259260
```
260261
## Key phrase extraction
261262

0 commit comments

Comments
 (0)