@@ -95,7 +95,7 @@ public static void main(String[] args) throws Exception {
95
95
* Identifies entities in the string {@code text}.
96
96
*/
97
97
public static void analyzeEntitiesText (String text ) throws Exception {
98
- // [START analyze_entities_text ]
98
+ // [START language_entities_text ]
99
99
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
100
100
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
101
101
Document doc = Document .newBuilder ()
@@ -124,14 +124,14 @@ public static void analyzeEntitiesText(String text) throws Exception {
124
124
}
125
125
}
126
126
}
127
- // [END analyze_entities_text ]
127
+ // [END language_entities_text ]
128
128
}
129
129
130
130
/**
131
131
* Identifies entities in the contents of the object at the given GCS {@code path}.
132
132
*/
133
133
public static void analyzeEntitiesFile (String gcsUri ) throws Exception {
134
- // [START analyze_entities_gcs ]
134
+ // [START language_entities_file_gcs ]
135
135
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
136
136
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
137
137
// set the GCS Content URI path to the file to be analyzed
@@ -161,14 +161,14 @@ public static void analyzeEntitiesFile(String gcsUri) throws Exception {
161
161
}
162
162
}
163
163
}
164
- // [END analyze_entities_gcs ]
164
+ // [END language_entities_file_gcs ]
165
165
}
166
166
167
167
/**
168
168
* Identifies the sentiment in the string {@code text}.
169
169
*/
170
170
public static Sentiment analyzeSentimentText (String text ) throws Exception {
171
- // [START analyze_sentiment_text ]
171
+ // [START language_sentiment_text ]
172
172
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
173
173
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
174
174
Document doc = Document .newBuilder ()
@@ -185,14 +185,14 @@ public static Sentiment analyzeSentimentText(String text) throws Exception {
185
185
}
186
186
return sentiment ;
187
187
}
188
- // [END analyze_sentiment_text ]
188
+ // [END language_sentiment_text ]
189
189
}
190
190
191
191
/**
192
192
* Gets {@link Sentiment} from the contents of the GCS hosted file.
193
193
*/
194
194
public static Sentiment analyzeSentimentFile (String gcsUri ) throws Exception {
195
- // [START analyze_sentiment_file ]
195
+ // [START language_sentiment_file_gcs ]
196
196
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
197
197
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
198
198
Document doc = Document .newBuilder ()
@@ -209,14 +209,14 @@ public static Sentiment analyzeSentimentFile(String gcsUri) throws Exception {
209
209
}
210
210
return sentiment ;
211
211
}
212
- // [END analyze_sentiment_file ]
212
+ // [END language_sentiment_file_gcs ]
213
213
}
214
214
215
215
/**
216
216
* from the string {@code text}.
217
217
*/
218
218
public static List <Token > analyzeSyntaxText (String text ) throws Exception {
219
- // [START analyze_syntax_text ]
219
+ // [START language_syntax_text ]
220
220
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
221
221
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
222
222
Document doc = Document .newBuilder ()
@@ -252,14 +252,14 @@ public static List<Token> analyzeSyntaxText(String text) throws Exception {
252
252
}
253
253
return response .getTokensList ();
254
254
}
255
- // [END analyze_syntax_text ]
255
+ // [END language_syntax_text ]
256
256
}
257
257
258
258
/**
259
259
* Get the syntax of the GCS hosted file.
260
260
*/
261
261
public static List <Token > analyzeSyntaxFile (String gcsUri ) throws Exception {
262
- // [START analyze_syntax_file ]
262
+ // [START language_syntax_file_gcs ]
263
263
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
264
264
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
265
265
Document doc = Document .newBuilder ()
@@ -296,14 +296,14 @@ public static List<Token> analyzeSyntaxFile(String gcsUri) throws Exception {
296
296
297
297
return response .getTokensList ();
298
298
}
299
- // [END analyze_syntax_file ]
299
+ // [END language_syntax_file_gcs ]
300
300
}
301
301
302
302
/**
303
303
* Detects categories in text using the Language Beta API.
304
304
*/
305
305
public static void classifyText (String text ) throws Exception {
306
- // [START classify_text ]
306
+ // [START language_classify_text ]
307
307
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
308
308
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
309
309
// set content to the text string
@@ -322,14 +322,14 @@ public static void classifyText(String text) throws Exception {
322
322
category .getName (), category .getConfidence ());
323
323
}
324
324
}
325
- // [END classify_text ]
325
+ // [END language_classify_text ]
326
326
}
327
327
328
328
/**
329
329
* Detects categories in a GCS hosted file using the Language Beta API.
330
330
*/
331
331
public static void classifyFile (String gcsUri ) throws Exception {
332
- // [START classify_file ]
332
+ // [START language_classify_file_gcs ]
333
333
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
334
334
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
335
335
// set the GCS content URI path
@@ -348,14 +348,14 @@ public static void classifyFile(String gcsUri) throws Exception {
348
348
category .getName (), category .getConfidence ());
349
349
}
350
350
}
351
- // [END classify_file ]
351
+ // [END language_classify_file_gcs ]
352
352
}
353
353
354
354
/**
355
355
* Detects the entity sentiments in the string {@code text} using the Language Beta API.
356
356
*/
357
357
public static void entitySentimentText (String text ) throws Exception {
358
- // [START entity_sentiment_text ]
358
+ // [START language_entity_sentiment_text ]
359
359
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
360
360
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
361
361
Document doc = Document .newBuilder ()
@@ -379,14 +379,14 @@ public static void entitySentimentText(String text) throws Exception {
379
379
}
380
380
}
381
381
}
382
- // [END entity_sentiment_text ]
382
+ // [END language_entity_sentiment_text ]
383
383
}
384
384
385
385
/**
386
386
* Identifies the entity sentiments in the the GCS hosted file using the Language Beta API.
387
387
*/
388
388
public static void entitySentimentFile (String gcsUri ) throws Exception {
389
- // [START entity_sentiment_file ]
389
+ // [START language_entity_sentiment_file_gcs ]
390
390
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
391
391
try (LanguageServiceClient language = LanguageServiceClient .create ()) {
392
392
Document doc = Document .newBuilder ()
@@ -413,6 +413,6 @@ public static void entitySentimentFile(String gcsUri) throws Exception {
413
413
}
414
414
}
415
415
}
416
- // [END entity_sentiment_file ]
416
+ // [END language_entity_sentiment_file_gcs ]
417
417
}
418
418
}
0 commit comments