22
22
import com .google .api .client .http .HttpRequestInitializer ;
23
23
import com .google .api .client .json .JsonFactory ;
24
24
import com .google .api .client .json .jackson2 .JacksonFactory ;
25
- import com .google .api .services .language .v1 .CloudNaturalLanguageAPI ;
26
- import com .google .api .services .language .v1 .CloudNaturalLanguageAPIScopes ;
25
+ import com .google .api .services .language .v1 .CloudNaturalLanguage ;
26
+ import com .google .api .services .language .v1 .CloudNaturalLanguageScopes ;
27
27
import com .google .api .services .language .v1 .model .AnalyzeEntitiesRequest ;
28
28
import com .google .api .services .language .v1 .model .AnalyzeEntitiesResponse ;
29
29
import com .google .api .services .language .v1 .model .AnalyzeSentimentRequest ;
@@ -157,12 +157,12 @@ public static void printSyntax(PrintStream out, List<Token> tokens) {
157
157
/**
158
158
* Connects to the Natural Language API using Application Default Credentials.
159
159
*/
160
- public static CloudNaturalLanguageAPI getLanguageService ()
160
+ public static CloudNaturalLanguage getLanguageService ()
161
161
throws IOException , GeneralSecurityException {
162
162
GoogleCredential credential =
163
- GoogleCredential .getApplicationDefault ().createScoped (CloudNaturalLanguageAPIScopes .all ());
163
+ GoogleCredential .getApplicationDefault ().createScoped (CloudNaturalLanguageScopes .all ());
164
164
JsonFactory jsonFactory = JacksonFactory .getDefaultInstance ();
165
- return new CloudNaturalLanguageAPI .Builder (
165
+ return new CloudNaturalLanguage .Builder (
166
166
GoogleNetHttpTransport .newTrustedTransport (),
167
167
jsonFactory , new HttpRequestInitializer () {
168
168
@ Override
@@ -174,12 +174,12 @@ public void initialize(HttpRequest request) throws IOException {
174
174
.build ();
175
175
}
176
176
177
- private final CloudNaturalLanguageAPI languageApi ;
177
+ private final CloudNaturalLanguage languageApi ;
178
178
179
179
/**
180
180
* Constructs a {@link Analyze} which connects to the Cloud Natural Language API.
181
181
*/
182
- public Analyze (CloudNaturalLanguageAPI languageApi ) {
182
+ public Analyze (CloudNaturalLanguage languageApi ) {
183
183
this .languageApi = languageApi ;
184
184
}
185
185
@@ -191,7 +191,7 @@ public List<Entity> analyzeEntities(String text) throws IOException {
191
191
new AnalyzeEntitiesRequest ()
192
192
.setDocument (new Document ().setContent (text ).setType ("PLAIN_TEXT" ))
193
193
.setEncodingType ("UTF16" );
194
- CloudNaturalLanguageAPI .Documents .AnalyzeEntities analyze =
194
+ CloudNaturalLanguage .Documents .AnalyzeEntities analyze =
195
195
languageApi .documents ().analyzeEntities (request );
196
196
197
197
AnalyzeEntitiesResponse response = analyze .execute ();
@@ -205,7 +205,7 @@ public Sentiment analyzeSentiment(String text) throws IOException {
205
205
AnalyzeSentimentRequest request =
206
206
new AnalyzeSentimentRequest ()
207
207
.setDocument (new Document ().setContent (text ).setType ("PLAIN_TEXT" ));
208
- CloudNaturalLanguageAPI .Documents .AnalyzeSentiment analyze =
208
+ CloudNaturalLanguage .Documents .AnalyzeSentiment analyze =
209
209
languageApi .documents ().analyzeSentiment (request );
210
210
211
211
AnalyzeSentimentResponse response = analyze .execute ();
@@ -220,7 +220,7 @@ public List<Token> analyzeSyntax(String text) throws IOException {
220
220
new AnalyzeSyntaxRequest ()
221
221
.setDocument (new Document ().setContent (text ).setType ("PLAIN_TEXT" ))
222
222
.setEncodingType ("UTF16" );
223
- CloudNaturalLanguageAPI .Documents .AnalyzeSyntax analyze =
223
+ CloudNaturalLanguage .Documents .AnalyzeSyntax analyze =
224
224
languageApi .documents ().analyzeSyntax (request );
225
225
AnalyzeSyntaxResponse response = analyze .execute ();
226
226
return response .getTokens ();
0 commit comments