@@ -96,10 +96,10 @@ Create a method to instantiate the `TextAnalyticsClient` object with the key and
96
96
97
97
``` java
98
98
static TextAnalyticsClient authenticateClient(String key, String endpoint) {
99
- return new TextAnalyticsClientBuilder ()
100
- .credential(new AzureKeyCredential (key))
101
- .endpoint(endpoint)
102
- .buildClient();
99
+ return new TextAnalyticsClientBuilder ()
100
+ .credential(new AzureKeyCredential (key))
101
+ .endpoint(endpoint)
102
+ .buildClient();
103
103
}
104
104
```
105
105
@@ -130,8 +130,8 @@ static void sentimentAnalysisExample(TextAnalyticsClient client)
130
130
sentenceSentiment. getConfidenceScores(). getPositive(),
131
131
sentenceSentiment. getConfidenceScores(). getNeutral(),
132
132
sentenceSentiment. getConfidenceScores(). getNegative());
133
+ }
133
134
}
134
- }
135
135
```
136
136
137
137
### Output
@@ -152,14 +152,14 @@ Create a new function called `detectLanguageExample()` that takes the client tha
152
152
``` java
153
153
static void detectLanguageExample(TextAnalyticsClient client)
154
154
{
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());
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());
163
163
}
164
164
```
165
165
@@ -180,17 +180,17 @@ Create a new function called `recognizeEntitiesExample()` that takes the client
180
180
``` java
181
181
static void recognizeEntitiesExample(TextAnalyticsClient client)
182
182
{
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
+ }
194
194
}
195
195
```
196
196
@@ -209,27 +209,27 @@ Create a new function called `recognizeLinkedEntitiesExample()` that takes the c
209
209
``` java
210
210
static void recognizeLinkedEntitiesExample(TextAnalyticsClient client)
211
211
{
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
- }
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
+ }
233
233
}
234
234
```
235
235
0 commit comments