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 .v1beta1 .CloudNaturalLanguageAPI ;
26
- import com .google .api .services .language .v1beta1 .CloudNaturalLanguageAPIScopes ;
25
+ import com .google .api .services .language .v1beta1 .CloudNaturalLanguage ;
26
+ import com .google .api .services .language .v1beta1 .CloudNaturalLanguageScopes ;
27
27
import com .google .api .services .language .v1beta1 .model .AnalyzeEntitiesRequest ;
28
28
import com .google .api .services .language .v1beta1 .model .AnalyzeEntitiesResponse ;
29
29
import com .google .api .services .language .v1beta1 .model .AnalyzeSentimentRequest ;
@@ -136,12 +136,12 @@ public static void printSyntax(PrintStream out, List<Token> tokens) {
136
136
/**
137
137
* Connects to the Natural Language API using Application Default Credentials.
138
138
*/
139
- public static CloudNaturalLanguageAPI getLanguageService ()
139
+ public static CloudNaturalLanguage getLanguageService ()
140
140
throws IOException , GeneralSecurityException {
141
141
GoogleCredential credential =
142
- GoogleCredential .getApplicationDefault ().createScoped (CloudNaturalLanguageAPIScopes .all ());
142
+ GoogleCredential .getApplicationDefault ().createScoped (CloudNaturalLanguageScopes .all ());
143
143
JsonFactory jsonFactory = JacksonFactory .getDefaultInstance ();
144
- return new CloudNaturalLanguageAPI .Builder (
144
+ return new CloudNaturalLanguage .Builder (
145
145
GoogleNetHttpTransport .newTrustedTransport (),
146
146
jsonFactory , new HttpRequestInitializer () {
147
147
@ Override
@@ -153,12 +153,12 @@ public void initialize(HttpRequest request) throws IOException {
153
153
.build ();
154
154
}
155
155
156
- private final CloudNaturalLanguageAPI languageApi ;
156
+ private final CloudNaturalLanguage languageApi ;
157
157
158
158
/**
159
159
* Constructs a {@link Analyze} which connects to the Cloud Natural Language API.
160
160
*/
161
- public Analyze (CloudNaturalLanguageAPI languageApi ) {
161
+ public Analyze (CloudNaturalLanguage languageApi ) {
162
162
this .languageApi = languageApi ;
163
163
}
164
164
@@ -170,7 +170,7 @@ public List<Entity> analyzeEntities(String text) throws IOException {
170
170
new AnalyzeEntitiesRequest ()
171
171
.setDocument (new Document ().setContent (text ).setType ("PLAIN_TEXT" ))
172
172
.setEncodingType ("UTF16" );
173
- CloudNaturalLanguageAPI .Documents .AnalyzeEntities analyze =
173
+ CloudNaturalLanguage .Documents .AnalyzeEntities analyze =
174
174
languageApi .documents ().analyzeEntities (request );
175
175
176
176
AnalyzeEntitiesResponse response = analyze .execute ();
@@ -184,7 +184,7 @@ public Sentiment analyzeSentiment(String text) throws IOException {
184
184
AnalyzeSentimentRequest request =
185
185
new AnalyzeSentimentRequest ()
186
186
.setDocument (new Document ().setContent (text ).setType ("PLAIN_TEXT" ));
187
- CloudNaturalLanguageAPI .Documents .AnalyzeSentiment analyze =
187
+ CloudNaturalLanguage .Documents .AnalyzeSentiment analyze =
188
188
languageApi .documents ().analyzeSentiment (request );
189
189
190
190
AnalyzeSentimentResponse response = analyze .execute ();
@@ -200,7 +200,7 @@ public List<Token> analyzeSyntax(String text) throws IOException {
200
200
.setDocument (new Document ().setContent (text ).setType ("PLAIN_TEXT" ))
201
201
.setFeatures (new Features ().setExtractSyntax (true ))
202
202
.setEncodingType ("UTF16" );
203
- CloudNaturalLanguageAPI .Documents .AnnotateText analyze =
203
+ CloudNaturalLanguage .Documents .AnnotateText analyze =
204
204
languageApi .documents ().annotateText (request );
205
205
206
206
AnnotateTextResponse response = analyze .execute ();
0 commit comments