@@ -115,21 +115,21 @@ static void sentimentAnalysisExample(TextAnalyticsClient client)
115
115
String text = " I had the best day of my life. I wish you were there with me." ;
116
116
117
117
DocumentSentiment documentSentiment = client. analyzeSentiment(text);
118
- System . out. printf(
119
- " Recognized document sentiment: %s, positive score: %.2f, neutral score: %.2f, negative score: %.2f.%n" ,
120
- documentSentiment. getSentiment(),
121
- documentSentiment. getSentimentScores(). getPositive(),
122
- documentSentiment. getSentimentScores(). getNeutral(),
123
- documentSentiment. getSentimentScores(). getNegative());
124
-
125
- for (SentenceSentiment sentenceSentiment : documentSentiment. getSentences()) {
126
118
System . out. printf(
127
- " Recognized sentence sentiment: %s, positive score: %.2f, neutral score: %.2f, negative score: %.2f.%n" ,
128
- sentenceSentiment. getSentiment(),
129
- sentenceSentiment. getSentimentScores(). getPositive(),
130
- sentenceSentiment. getSentimentScores(). getNeutral(),
131
- sentenceSentiment. getSentimentScores(). getNegative());
132
- }
119
+ " Recognized document sentiment: %s, positive score: %.2f, neutral score: %.2f, negative score: %.2f.%n" ,
120
+ documentSentiment. getSentiment(),
121
+ documentSentiment. getSentimentScores(). getPositive(),
122
+ documentSentiment. getSentimentScores(). getNeutral(),
123
+ documentSentiment. getSentimentScores(). getNegative());
124
+
125
+ for (SentenceSentiment sentenceSentiment : documentSentiment. getSentences()) {
126
+ System . out. printf(
127
+ " Recognized sentence sentiment: %s, positive score: %.2f, neutral score: %.2f, negative score: %.2f.%n" ,
128
+ sentenceSentiment. getSentiment(),
129
+ sentenceSentiment. getSentimentScores(). getPositive(),
130
+ sentenceSentiment. getSentimentScores(). getNeutral(),
131
+ sentenceSentiment. getSentimentScores(). getNegative());
132
+ }
133
133
}
134
134
```
135
135
@@ -154,7 +154,7 @@ static void detectLanguageExample(TextAnalyticsClient client)
154
154
String text = " Ce document est rédigé en Français." ;
155
155
156
156
DetectedLanguage detectedLanguage = client. detectLanguage(text);
157
- System . out. printf(" Detected primary language: %s, ISO 6391 name: %s, score: %s .%n" ,
157
+ System . out. printf(" Detected primary language: %s, ISO 6391 name: %s, score: %.2f .%n" ,
158
158
detectedLanguage. getName(),
159
159
detectedLanguage. getIso6391Name(),
160
160
detectedLanguage. getScore());
@@ -164,7 +164,7 @@ static void detectLanguageExample(TextAnalyticsClient client)
164
164
### Output
165
165
166
166
``` console
167
- Detected primary language: French, ISO 6391 name: fr, score: 1.0 .
167
+ Detected primary language: French, ISO 6391 name: fr, score: 1.00 .
168
168
```
169
169
## Named Entity recognition (NER)
170
170
@@ -183,7 +183,7 @@ static void recognizeEntitiesExample(TextAnalyticsClient client)
183
183
184
184
for (CategorizedEntity entity : client. recognizeEntities(text)) {
185
185
System . out. printf(
186
- " Recognized entity: %s, entity category: %s, entity sub-category: %s, offset: %s, length: %s, score: %s .%n" ,
186
+ " Recognized entity: %s, entity category: %s, entity sub-category: %s, offset: %s, length: %s, score: %.2f .%n" ,
187
187
entity. getText(),
188
188
entity. getCategory(),
189
189
entity. getSubCategory() == null || entity. getSubCategory(). isEmpty() ? " N/A" : entity. getSubCategory(),
@@ -198,7 +198,7 @@ static void recognizeEntitiesExample(TextAnalyticsClient client)
198
198
199
199
``` console
200
200
Recognized entity: Seattle, entity category: Location, entity sub-category: GPE, offset: 26, length: 7, score: 0.92.
201
- Recognized entity: last week, entity category: DateTime, entity sub-category: DateRange, offset: 34, length: 9, score: 0.8 .
201
+ Recognized entity: last week, entity category: DateTime, entity sub-category: DateRange, offset: 34, length: 9, score: 0.80 .
202
202
```
203
203
204
204
## Using NER to detect personal information
@@ -213,7 +213,7 @@ static void recognizePIIEntitiesExample(TextAnalyticsClient client)
213
213
214
214
for (PiiEntity entity : client. recognizePiiEntities(text)) {
215
215
System . out. printf(
216
- " Recognized personal identifiable information entity: %s, entity category: %s, entity sub-category: %s, offset: %s, length: %s, score: %s .%n" ,
216
+ " Recognized personal identifiable information entity: %s, entity category: %s, entity sub-category: %s, offset: %s, length: %s, score: %.2f .%n" ,
217
217
entity. getText(),
218
218
entity. getCategory(),
219
219
entity. getSubCategory() == null || entity. getSubCategory(). isEmpty() ? " N/A" : entity. getSubCategory(),
0 commit comments