From ece8166e5ee7b8be91ce266c4f0aae0bf4932f2e Mon Sep 17 00:00:00 2001 From: German Attanasio Ruiz Date: Mon, 1 Aug 2016 15:44:44 -0400 Subject: [PATCH 1/2] :bug: remove the deprecation from language translation --- .../v1/MicrophoneWithWebSocketsExample.java | 3 - .../model/MessageResponse.java | 23 +- .../v2/LanguageTranslation.java | 6 +- .../v2/model/CreateModelOptions.java | 3 +- .../v2/model/IdentifiableLanguage.java | 2 - .../v2/model/IdentifiedLanguage.java | 3 - .../v2/model/Language.java | 26 +- .../v2/model/Translation.java | 3 - .../v2/model/TranslationModel.java | 13 +- .../v2/model/TranslationModels.java | 6 +- .../v2/model/TranslationResult.java | 2 - .../v2/LanguageTranslator.java | 325 ------------------ .../v2/model/CreateModelOptions.java | 184 ---------- .../v2/model/IdentifiableLanguage.java | 67 ---- .../v2/model/IdentifiedLanguage.java | 46 --- .../v2/model/Language.java | 57 --- .../v2/model/Translation.java | 47 --- .../v2/model/TranslationModel.java | 230 ------------- .../v2/model/TranslationModels.java | 47 --- .../v2/model/TranslationResult.java | 98 ------ .../v2/model/package-info.java | 5 - .../language_translator/v2/package-info.java | 5 - .../v1/model/DiskUsageStats.java | 2 +- .../v1/model/MemoryUsageStats.java | 2 +- .../v1/model/SolrClusterResizeRequest.java | 15 +- .../v1/model/SolrClusterSizeResponse.java | 42 ++- .../developer_cloud/util/RequestUtils.java | 4 - .../developer_cloud/MultiThreadTest.java | 10 +- .../v2/LanguageTranslatorIT.java | 170 --------- .../v2/LanguageTranslatorTest.java | 304 ---------------- .../v1/RetrieveAndRankIT.java | 2 +- .../v1/RetrieveAndRankTest.java | 21 +- .../service/GenericServiceTest.java | 8 +- 33 files changed, 107 insertions(+), 1674 deletions(-) delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Language.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModel.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModels.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationResult.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/package-info.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/package-info.java delete mode 100644 src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorIT.java delete mode 100644 src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorTest.java diff --git a/examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java b/examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java index 9deffda6694..d62a27affbc 100644 --- a/examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java +++ b/examples/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java @@ -13,13 +13,10 @@ */ package com.ibm.watson.developer_cloud.speech_to_text.v1; -import java.io.FileNotFoundException; - import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; -import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.TargetDataLine; import com.ibm.watson.developer_cloud.http.HttpMediaType; diff --git a/src/main/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/model/MessageResponse.java b/src/main/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/model/MessageResponse.java index 1b7b8c3caa7..b4f3ce311ce 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/model/MessageResponse.java +++ b/src/main/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/model/MessageResponse.java @@ -24,8 +24,8 @@ * The response payload from the Conversation service's message API call * {@link ConversationService#message(String, MessageRequest)}. * - * @see - * http://www.ibm.com/watson/developercloud/conversation.html + * @see http://www.ibm.com/ + * watson/developercloud/conversation.html */ public class MessageResponse extends GenericModel { private static final String TEXT = "text"; @@ -243,6 +243,7 @@ public void setOutput(Map output) { * * @return an array of strings which is to be displayed/returned to the end user */ + @SuppressWarnings("unchecked") public List getText() { if (output != null && output.containsKey(TEXT)) { List text = (List) output.get(TEXT); @@ -257,7 +258,8 @@ public List getText() { * A convenience method for getting the text property from the output object. The text property is * an array of strings. This convenience class concatenates the array, separating each entry with * the separator string. - * + * + * @param separator the separator * @return a concatenation of the strings in the output array, with each string separated by the * separator string */ @@ -269,14 +271,29 @@ public String getTextConcatenated(String separator) { return null; } + /** + * Gets the input. + * + * @return the input + */ public Map getInput() { return input; } + /** + * Sets the input. + * + * @param input the input + */ public void setInput(Map input) { this.input = input; } + /** + * Gets the input text. + * + * @return the input text + */ public String getInputText() { if (this.input != null && this.input.containsKey(TEXT)) { return this.input.get(TEXT).toString(); diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java index b19c87c657e..57ce82ef8f3 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java @@ -44,15 +44,11 @@ * The IBM Watson Language Translator service translate text from one language to another and * identifies the language in which text is written. * - *

This class is deprecated. Use {@link com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator} - * instead.

- * * @version v2 * @see - * Language Translator + * Language translation */ -@Deprecated public class LanguageTranslation extends WatsonService { private static final String LANGUAGES = "languages"; diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/CreateModelOptions.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/CreateModelOptions.java index b9bd7e07b77..b712dc5b895 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/CreateModelOptions.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/CreateModelOptions.java @@ -15,14 +15,13 @@ package com.ibm.watson.developer_cloud.language_translation.v2.model; import java.io.File; + import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation; /** * Model Options when using the {@link LanguageTranslation#createModel(CreateModelOptions)} method. * - *

This class is deprecated. Use the {@code language_translator} classes instead.

*/ -@Deprecated public class CreateModelOptions { /** diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiableLanguage.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiableLanguage.java index dfff93bcbfd..4cee050aef4 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiableLanguage.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiableLanguage.java @@ -19,10 +19,8 @@ /** * Identifiable language used by the {@link LanguageTranslation} service. * - *

This class is deprecated. Use the {@code language_translator} classes instead.

* */ -@Deprecated public class IdentifiableLanguage extends GenericModel { private final String language; diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiedLanguage.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiedLanguage.java index 44d6359dbb4..fde8fb56401 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiedLanguage.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/IdentifiedLanguage.java @@ -18,10 +18,7 @@ /** * Language detected by the {@link LanguageTranslation} service. * - *

This class is deprecated. Use the {@code language_translator} classes instead.

- * */ -@Deprecated public class IdentifiedLanguage extends IdentifiableLanguage { /** The confidence. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Language.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Language.java index 34f85f67ac5..ee04e050e81 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Language.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Language.java @@ -17,25 +17,21 @@ /** * The languages available in {@link LanguageTranslation}. - * - *

This class is deprecated. Use the {@code language_translator} classes instead.

*/ -@Deprecated public enum Language { - /** arabic. */ ARABIC("ar"), - /** english. */ - ENGLISH("en"), - /** spanish. */ - SPANISH("es"), - /** french. */ - FRENCH("fr"), - /** italian. */ - ITALIAN("it"), - /** portuguese. */ - PORTUGUESE("pt"); - + /** english. */ + ENGLISH("en"), + /** spanish. */ + SPANISH("es"), + /** french. */ + FRENCH("fr"), + /** italian. */ + ITALIAN("it"), + /** portuguese. */ + PORTUGUESE("pt"); + /** language. */ String language; diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Translation.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Translation.java index eaf0f6c9483..940c1f0614c 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Translation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/Translation.java @@ -20,10 +20,7 @@ /** * The Translation result used as POJO by the {@link LanguageTranslation}. * - *

This class is deprecated. Use the {@code language_translator} classes instead.

- * */ -@Deprecated public class Translation extends GenericModel { /** The translation. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModel.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModel.java index 51355284ec9..cc88ce6acf2 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModel.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModel.java @@ -19,22 +19,17 @@ /** * Language Model used by the {@link TranslationModel}. * - *

This class is deprecated. Use the {@code language_translator} classes instead.

*/ -@Deprecated public class TranslationModel extends GenericModel { - + /** * The Enum Status. */ public enum Status { - /** The available. */ - AVAILABLE, - /** The error. */ - ERROR, - /** The training. */ - TRAINING; + AVAILABLE, /** The error. */ + ERROR, /** The training. */ + TRAINING; } @SerializedName("base_model_id") diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModels.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModels.java index 285d6da21d7..0a804c75f5f 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModels.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationModels.java @@ -13,18 +13,16 @@ */ package com.ibm.watson.developer_cloud.language_translation.v2.model; +import java.util.List; + import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation; import com.ibm.watson.developer_cloud.service.model.GenericModel; -import java.util.List; - /** * {@link TranslationModel} list used by the {@link LanguageTranslation} service. * - *

This class is deprecated. Use the {@code language_translator} classes instead.

*/ -@Deprecated public class TranslationModels extends GenericModel { private List models; diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java index d53526f3dd2..5ced36ea47c 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/model/TranslationResult.java @@ -22,9 +22,7 @@ * Translation results from calling the translate method. Contains the word count, character count * and the {@link Translation} list * - *

This class is deprecated. Use the {@code language_translator} classes instead.

*/ -@Deprecated public class TranslationResult extends GenericModel { @SerializedName("character_count") diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java deleted file mode 100644 index 94ba7ba6507..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java +++ /dev/null @@ -1,325 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.List; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ResponseConverter; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.Language; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; - -import okhttp3.MultipartBody; -import okhttp3.Request; -import okhttp3.RequestBody; - -/** - * The IBM Watson Language Translator service translate text from one language to another and - * identifies the language in which text is written. - * - * @version v2 - * @see - * Language Translator - */ -public class LanguageTranslator extends WatsonService { - - private static final String LANGUAGES = "languages"; - private static final String MODELS = "models"; - private static final String SERVICE_NAME = "language_translation"; - private static final String PATH_IDENTIFY = "/v2/identify"; - private static final String PATH_TRANSLATE = "/v2/translate"; - private static final String PATH_IDENTIFIABLE_LANGUAGES = "/v2/identifiable_languages"; - private static final String PATH_MODELS = "/v2/models"; - private static final String BASE_MODEL_ID = "base_model_id"; - private static final String DEFAULT = "default"; - private static final String FORCED_GLOSSARY = "forced_glossary"; - private static final String MODEL_ID = "model_id"; - private static final String MONOLINGUAL_CORPUS = "monolingual_corpus"; - private static final String NAME = "name"; - private static final String PARALLEL_CORPUS = "parallel_corpus"; - private static final String SOURCE = "source"; - private static final String TARGET = "target"; - private static final String TEXT = "text"; - private static final String URL = "https://gateway.watsonplatform.net/language-translation/api"; - private static final String PATH_MODEL = "/v2/models/%s"; - private static final Type TYPE_LIST_TRANSLATION_MODEL = new TypeToken>() {}.getType(); - private static final Type TYPE_LIST_IDENTIFIABLE_LANGUAGE = new TypeToken>() {}.getType(); - private static final Type TYPE_LIST_IDENTIFIED_LANGUAGE = new TypeToken>() {}.getType(); - - /** - * Instantiates a new Language Translator service. - */ - public LanguageTranslator() { - super(SERVICE_NAME); - setEndPoint(URL); - } - - /** - * Instantiates a new language translation service by username and password. - * @param username the username - * @param password the password - */ - public LanguageTranslator(String username, String password) { - this(); - setUsernameAndPassword(username, password); - } - - /** - * Creates a translation models. - * - * @param options the create model options - * @return the translation model - */ - public ServiceCall createModel(CreateModelOptions options) { - Validator.notNull(options, "options cannot be null"); - Validator.notEmpty(options.baseModelId(), "options.baseModelId cannot be null or empty"); - - final RequestBuilder requestBuilder = RequestBuilder.post(PATH_MODELS); - requestBuilder.query(BASE_MODEL_ID, options.baseModelId()); - - if (options.name() != null) - requestBuilder.query(NAME, options.name()); - - final MultipartBody.Builder bodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); - - // either forced glossary, monolingual corpus or parallel corpus should be specified - if (options.forcedGlossary() != null) - bodyBuilder.addFormDataPart(FORCED_GLOSSARY, options.forcedGlossary().getName(), - RequestBody.create(HttpMediaType.BINARY_FILE, options.forcedGlossary())); - if (options.monolingualCorpus() != null) - bodyBuilder.addFormDataPart(MONOLINGUAL_CORPUS, options.monolingualCorpus().getName(), - RequestBody.create(HttpMediaType.BINARY_FILE, options.monolingualCorpus())); - if (options.parallelCorpus() != null) - bodyBuilder.addFormDataPart(PARALLEL_CORPUS, options.parallelCorpus().getName(), - RequestBody.create(HttpMediaType.BINARY_FILE, options.parallelCorpus())); - - return createServiceCall(requestBuilder.body(bodyBuilder.build()).build(), - ResponseConverterUtils.getObject(TranslationModel.class)); - } - - /** - * Deletes a translation models. - * - * @param modelId the model identifier - * @return the service call - */ - public ServiceCall deleteModel(String modelId) { - if (modelId == null || modelId.isEmpty()) - throw new IllegalArgumentException("modelId cannot be null or empty"); - - Request request = RequestBuilder.delete(String.format(PATH_MODEL, modelId)).build(); - return createServiceCall(request, ResponseConverterUtils.getVoid()); - } - - /** - * Gets the The identifiable languages. - * - * @return the identifiable languages - * @see TranslationModel - * See {@link IdentifiableLanguage} - */ - public ServiceCall> getIdentifiableLanguages() { - final RequestBuilder requestBuilder = RequestBuilder.get(PATH_IDENTIFIABLE_LANGUAGES); - - ResponseConverter> converter = - ResponseConverterUtils.getGenericObject(TYPE_LIST_IDENTIFIABLE_LANGUAGE, LANGUAGES); - - return createServiceCall(requestBuilder.build(), converter); - - } - - /** - * Gets a translation models. - * - * @param modelId the model identifier - * @return the translation models - * @see TranslationModel - */ - public ServiceCall getModel(String modelId) { - Validator.isTrue(modelId != null && !modelId.isEmpty(), "modelId cannot be null or empty"); - Request request = RequestBuilder.get(String.format(PATH_MODEL, modelId)).build(); - return createServiceCall(request, ResponseConverterUtils.getObject(TranslationModel.class)); - } - - /** - * Gets the translation models. - * - * @return the translation models - * @see TranslationModel - */ - public ServiceCall> getModels() { - return getModels(null, null, null); - } - - /** - * Retrieves the list of models. - * - * @param showDefault show default models - * @param source the source - * @param target the target - * @return the translation models - * @see TranslationModel - */ - public ServiceCall> getModels(final Boolean showDefault, final String source, - final String target) { - final RequestBuilder requestBuilder = RequestBuilder.get(PATH_MODELS); - - if (source != null && !source.isEmpty()) - requestBuilder.query(SOURCE, source); - - if (target != null && !target.isEmpty()) - requestBuilder.query(TARGET, source); - - if (showDefault != null) - requestBuilder.query(DEFAULT, showDefault); - - ResponseConverter> converter = - ResponseConverterUtils.getGenericObject(TYPE_LIST_TRANSLATION_MODEL, MODELS); - - return createServiceCall(requestBuilder.build(), converter); - } - - /** - * Identify language in which text is written. - * - * @param text the text to identify - * @return the identified language - */ - public ServiceCall> identify(final String text) { - final RequestBuilder requestBuilder = RequestBuilder.post(PATH_IDENTIFY) - .header(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON).bodyContent(text, HttpMediaType.TEXT_PLAIN); - - ResponseConverter> converter = - ResponseConverterUtils.getGenericObject(TYPE_LIST_IDENTIFIED_LANGUAGE, LANGUAGES); - - return createServiceCall(requestBuilder.build(), converter); - } - - /** - * Translate text using a given model. - * - * @param text The submitted paragraphs to translate - * @param modelId the model id - * @return The {@link TranslationResult} - */ - public ServiceCall translate(final String text, final String modelId) { - return translate(Collections.singletonList(text), modelId); - } - - /** - * Translate text using source and target languages.
- *
- * Here is an example of how to translate "hello" from English to Spanish: - * - * - *
-   * LanguageTranslator service = new LanguageTranslator();
-   * service.setUsernameAndPassword("USERNAME", "PASSWORD");
-   *
-   * TranslationResult translationResult = service.translate("hello", Language.SPANISH, Language.ENGLISH).execute();
-   *
-   * System.out.println(translationResult);
-   * 
- * - * @param text The paragraphs to translate - * @param source The source language - * @param target The target language - * @return The {@link TranslationResult} - */ - public ServiceCall translate(final String text, final Language source, final Language target) { - return translate(Collections.singletonList(text), source, target); - } - - /** - * Translate multiple texts using a given model. - * - * @param texts The submitted texts to translate - * @param modelId the model id - * @return The {@link TranslationResult} with translations in the same order as the supplied texts. - */ - public ServiceCall translate(final List texts, final String modelId) { - Validator.isTrue(modelId != null && !modelId.isEmpty(), "modelId cannot be null or empty"); - return translateRequest(texts, modelId, null, null); - } - - /** - * Translate multiple texts using source and target languages. - * - * @param texts The texts to translate - * @param source The source language - * @param target The target language - * @return The {@link TranslationResult} with translations in the same order as the supplied texts. - */ - public ServiceCall translate(final List texts, final Language source, final Language target) { - return translateRequest(texts, null, source, target); - } - - /** - * Translate paragraphs of text using a model and or source and target. model_id or source and - * target needs to be specified. If both are specified, then only model_id will be used - * - * @param texts the texts - * @param modelId the model id - * @param source the source - * @param target the target - * @return The {@link TranslationResult} - */ - private ServiceCall translateRequest(List texts, String modelId, Language source, - Language target) { - Validator.isTrue(texts != null && !texts.isEmpty(), "texts cannot be null or empty"); - - final JsonObject contentJson = new JsonObject(); - - // convert the text into a json array - final JsonArray paragraphs = new JsonArray(); - for(String text : texts) { - Validator.notNull(text, "text cannot be null"); - paragraphs.add(new JsonPrimitive(text)); - } - contentJson.add(TEXT, paragraphs); - - final RequestBuilder requestBuilder = - RequestBuilder.post(PATH_TRANSLATE).header(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON); - - if (source != null) - contentJson.addProperty(SOURCE, source.toString()); - - if (target != null) - contentJson.addProperty(TARGET, target.toString()); - - if (modelId != null && !modelId.isEmpty()) - contentJson.addProperty(MODEL_ID, modelId); - - requestBuilder.bodyJson(contentJson); - return createServiceCall(requestBuilder.build(), ResponseConverterUtils.getObject(TranslationResult.class)); - } - -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java deleted file mode 100644 index 9222573e105..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.io.File; -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; - -/** - * Model Options when using the {@link LanguageTranslator#createModel(CreateModelOptions)} method. - * - */ -public class CreateModelOptions { - - /** - * Builder. - */ - public static class Builder { - private String baseModelId; - private File forcedGlossary; - private File monolingualCorpus; - private String name; - private File parallelCorpus; - - private Builder(CreateModelOptions options) { - this.name = options.name; - this.baseModelId = options.baseModelId; - this.parallelCorpus = options.parallelCorpus; - this.monolingualCorpus = options.monolingualCorpus; - this.forcedGlossary = options.forcedGlossary; - } - - /** - * Instantiates a new builder. - */ - public Builder() {} - - /** - * Base model id. - * - * @param baseModelId the base model id - * @return the creates the model options - */ - public Builder baseModelId(String baseModelId) { - this.baseModelId = baseModelId; - return this; - } - - /** - * Builds the model creation options. - * - * @return the model creation options - */ - public CreateModelOptions build() { - return new CreateModelOptions(this); - } - - /** - * With forced glossary. - * - * @param forcedGlossary the forced glossary - * @return the creates the model options - */ - public Builder forcedGlossary(File forcedGlossary) { - this.forcedGlossary = forcedGlossary; - return this; - } - - /** - * Sets the monolingual corpus. - * - * @param monolingualCorpus the monolingual corpus - * @return the creates the model options - */ - public Builder monolingualCorpus(File monolingualCorpus) { - this.monolingualCorpus = monolingualCorpus; - return this; - } - - /** - * Sets the name. - * - * @param name the name - * @return the profile options - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Sets the parallel corpus. - * - * @param parallelCorpus the parallel corpus - * @return the creates the model options - */ - public Builder parallelCorpus(File parallelCorpus) { - this.parallelCorpus = parallelCorpus; - return this; - } - } - - private String baseModelId; - private File forcedGlossary; - private File monolingualCorpus; - private String name; - private File parallelCorpus; - - private CreateModelOptions(Builder builder) { - this.baseModelId = builder.baseModelId; - this.forcedGlossary = builder.forcedGlossary; - this.parallelCorpus = builder.parallelCorpus; - this.name = builder.name; - this.monolingualCorpus = builder.monolingualCorpus; - } - - /** - * Gets the base model id. - * - * @return the baseModelId - */ - public String baseModelId() { - return baseModelId; - } - - /** - * Gets the forced glossary. - * - * @return the forcedGlossary - */ - public File forcedGlossary() { - return forcedGlossary; - } - - /** - * Gets the monolingual corpus. - * - * @return the monolingualCorpus - */ - public File monolingualCorpus() { - return monolingualCorpus; - } - - /** - * Gets the name. - * - * @return the name - */ - public String name() { - return name; - } - - /** - * New builder. - * - * @return the builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the parallel corpus. - * - * @return the parallelCorpus - */ - public File parallelCorpus() { - return parallelCorpus; - } - -} - - diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java deleted file mode 100644 index da4f00966e4..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Identifiable language used by the {@link LanguageTranslator} service. - * - */ -public class IdentifiableLanguage extends GenericModel { - - private final String language; - private final String name; - - /** - * Instantiates a new language. - * - * @param language the language - */ - public IdentifiableLanguage(final String language) { - this.language = language; - this.name = null; - } - - /** - * Instantiates a new identifiable language. - * - * @param language the language - * @param name the name - */ - public IdentifiableLanguage(final String language, final String name) { - super(); - this.language = language; - this.name = name; - } - - /** - * Gets the language. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java deleted file mode 100644 index 22e95aff5ad..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; - -/** - * Language detected by the {@link LanguageTranslator} service. - * - */ -public class IdentifiedLanguage extends IdentifiableLanguage { - - /** The confidence. */ - private final Double confidence; - - /** - * Instantiates a new language. - * - * @param language the language - * @param confidence the confidence - */ - public IdentifiedLanguage(final String language, final Double confidence) { - super(language); - this.confidence = confidence; - } - - /** - * Gets the confidence. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Language.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Language.java deleted file mode 100644 index a619726e001..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Language.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; - -/** - * The languages available in {@link LanguageTranslator}. - */ -public enum Language { - - /** arabic. */ - ARABIC("ar"), - /** english. */ - ENGLISH("en"), - /** spanish. */ - SPANISH("es"), - /** french. */ - FRENCH("fr"), - /** italian. */ - ITALIAN("it"), - /** portuguese. */ - PORTUGUESE("pt"); - - /** language. */ - String language; - - /** - * Instantiates a new language. - * - * @param language the language - */ - Language(String language) { - this.language = language; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Enum#toString() - */ - @Override - public String toString() { - return language; - } -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java deleted file mode 100644 index 64382d5d35a..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.google.gson.annotations.Expose; -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The Translation result used as POJO by the {@link LanguageTranslator}. - * - */ -public class Translation extends GenericModel { - - /** The translation. */ - @Expose - private String translation; - - /** - * Gets the translation. - * - * @return The translation - */ - public String getTranslation() { - return translation; - } - - /** - * Sets the translation. - * - * @param translation The translation - */ - public void setTranslation(final String translation) { - this.translation = translation; - } -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModel.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModel.java deleted file mode 100644 index 2ff159c2ff1..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModel.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Language Model used by the {@link TranslationModel}. - */ -public class TranslationModel extends GenericModel { - - /** - * The Enum Status. - */ - public enum Status { - - /** The available. */ - AVAILABLE, - /** The error. */ - ERROR, - /** The training. */ - TRAINING; - } - - @SerializedName("base_model_id") - private String baseModelId; - private Boolean customizable; - @SerializedName("default_model") - private Boolean defaultModel; - private String domain; - @SerializedName("model_id") - private String id; - private String name; - private String owner; - private String source; - private Status status; - private String target; - - /** - * Gets the base model id. - * - * @return The baseModelId - */ - public String getBaseModelId() { - return baseModelId; - } - - /** - * Gets the domain. - * - * @return The domain - */ - public String getDomain() { - return domain; - } - - /** - * Gets the model id. - * - * @return The modelId - */ - public String getId() { - return id; - } - - /** - * Gets the name. - * - * @return The name - */ - public String getName() { - return name; - } - - /** - * Gets the owner. - * - * @return The owner - */ - public String getOwner() { - return owner; - } - - /** - * Gets the source. - * - * @return The source - */ - public String getSource() { - return source; - } - - /** - * Gets the status. - * - * @return The status - */ - public Status getStatus() { - return status; - } - - /** - * Gets the target. - * - * @return The target - */ - public String getTarget() { - return target; - } - - /** - * Checks if is customizable. - * - * @return The customizable - */ - public boolean isCustomizable() { - return customizable; - } - - /** - * Checks if is default model. - * - * @return The defaultModel - */ - public boolean isDefaultModel() { - return defaultModel; - } - - /** - * Sets the base model id. - * - * @param baseModelId The base_model_id - */ - public void setBaseModelId(final String baseModelId) { - this.baseModelId = baseModelId; - } - - /** - * Sets the customizable. - * - * @param customizable The customizable - */ - public void setCustomizable(final boolean customizable) { - this.customizable = customizable; - } - - /** - * Sets the default model. - * - * @param defaultModel The default_model - */ - public void setDefaultModel(final boolean defaultModel) { - this.defaultModel = defaultModel; - } - - /** - * Sets the domain. - * - * @param domain The domain - */ - public void setDomain(final String domain) { - this.domain = domain; - } - - /** - * Sets the model id. - * - * @param id The model id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Sets the name. - * - * @param name The name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Sets the owner. - * - * @param owner The owner - */ - public void setOwner(final String owner) { - this.owner = owner; - } - - /** - * Sets the source. - * - * @param source The source - */ - public void setSource(final String source) { - this.source = source; - } - - /** - * Sets the status. - * - * @param status The status - */ - public void setStatus(final Status status) { - this.status = status; - } - - /** - * Sets the target. - * - * @param target The target - */ - public void setTarget(final String target) { - this.target = target; - } -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModels.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModels.java deleted file mode 100644 index f965111706e..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModels.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - - -/** - * {@link TranslationModel} list used by the {@link LanguageTranslator} service. - */ -public class TranslationModels extends GenericModel { - - private List models; - - /** - * Gets the models. - * - * @return the models - */ - public List getModels() { - return models; - } - - /** - * Sets the models. - * - * @param models the models to set - */ - public void setModels(List models) { - this.models = models; - } - -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationResult.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationResult.java deleted file mode 100644 index 0d53c339072..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationResult.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Translation results from calling the translate method. Contains the word count, character count - * and the {@link Translation} list - */ -public class TranslationResult extends GenericModel { - - @SerializedName("character_count") - private Integer characterCount; - private List translations; - @SerializedName("word_count") - private Integer wordCount; - - /** - * Gets the character count. - * - * @return The characterCount - */ - public Integer getCharacterCount() { - return characterCount; - } - - /** - * Gets the first translation. - * - * @return the first translation, or null if none found - */ - public String getFirstTranslation() { - if (translations != null && !translations.isEmpty()) - return translations.get(0).getTranslation(); - else - return null; - } - - /** - * Gets the translations. - * - * @return The translations - */ - public List getTranslations() { - return translations; - } - - /** - * Gets the word count. - * - * @return The word count - */ - public Integer getWordCount() { - return wordCount; - } - - /** - * Sets the character count. - * - * @param characterCount The character count - */ - public void setCharacterCount(final Integer characterCount) { - this.characterCount = characterCount; - } - - /** - * Sets the translations. - * - * @param translations The translations - */ - public void setTranslations(final List translations) { - this.translations = translations; - } - - /** - * Sets the word count. - * - * @param wordCount The word count - */ - public void setWordCount(final Integer wordCount) { - this.wordCount = wordCount; - } -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/package-info.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/package-info.java deleted file mode 100644 index 9ff736e484d..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Classes that map the HTTP service requests and responses into POJOs - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/package-info.java b/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/package-info.java deleted file mode 100644 index 5c60e3d8e7d..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Language Translator Service v2 - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/DiskUsageStats.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/DiskUsageStats.java index 58ab6ce2c42..fc13cab1c3c 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/DiskUsageStats.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/DiskUsageStats.java @@ -19,7 +19,7 @@ import com.ibm.watson.developer_cloud.service.model.GenericModel; /** - * Disk Usage Stats + * Disk Usage Stats. */ public class DiskUsageStats extends GenericModel { diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/MemoryUsageStats.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/MemoryUsageStats.java index 02548cbd7c1..d4cc0eff20c 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/MemoryUsageStats.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/MemoryUsageStats.java @@ -19,7 +19,7 @@ import com.ibm.watson.developer_cloud.service.model.GenericModel; /** - * Memory Usage Stats + * Memory Usage Stats. */ public class MemoryUsageStats extends GenericModel { diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterResizeRequest.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterResizeRequest.java index 819b1ad318c..b1eed7103dd 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterResizeRequest.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterResizeRequest.java @@ -1,11 +1,11 @@ -/** +/* * Copyright 2016 IBM Corp. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under @@ -27,7 +27,7 @@ public class SolrClusterResizeRequest { private final int clusterSize; /** - * Instantiates a cluster resize request + * Instantiates a cluster resize request. * * @param clusterSize the desired cluster size */ @@ -35,6 +35,11 @@ public SolrClusterResizeRequest(final int clusterSize) { this.clusterSize = clusterSize; } + /** + * Gets the cluster size. + * + * @return the cluster size + */ @SerializedName(CLUSTER_SIZE) public int getClusterSize() { return clusterSize; diff --git a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterSizeResponse.java b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterSizeResponse.java index b11c8171ad7..b1e47eca034 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterSizeResponse.java +++ b/src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/model/SolrClusterSizeResponse.java @@ -1,11 +1,11 @@ -/** - * Copyright 2016 IBM Corp. All Rights Reserved. - * +/* + * Copyright 2015 IBM Corp. All Rights Reserved. + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under @@ -23,8 +23,15 @@ */ public class SolrClusterSizeResponse extends GenericModel { + /** + * The Enum Status. + */ public enum Status { + + /** The resizing. */ RESIZING, + + /** The error. */ ERROR } @@ -72,26 +79,51 @@ public SolrClusterSizeResponse(final String clusterId, final Integer currentSize this.message = message; } + /** + * Ge cluster id. + * + * @return the string + */ @SerializedName(CLUSTER_ID) public String geClusterId() { return clusterId; } + /** + * Gets the status. + * + * @return the status + */ @SerializedName(RESIZE_STATUS) public Status getStatus() { return status; } + /** + * Gets the current size. + * + * @return the current size + */ @SerializedName(CLUSTER_SIZE) public Integer getCurrentSize() { return currentSize; } + /** + * Gets the target size. + * + * @return the target size + */ @SerializedName(TARGET_CLUSTER_SIZE) public Integer getTargetSize() { return targetSize; } + /** + * Gets the message. + * + * @return the message + */ @SerializedName(RESIZE_MESSAGE) public String getMessage() { return message; diff --git a/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java b/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java index 864938972a6..6003fda2609 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java +++ b/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java @@ -188,10 +188,6 @@ private static String loadSdkVersion() { return properties.getProperty("version", "unknown-version"); } - public static void main(String[] args) { - System.out.println(getUserAgent()); - } - /** * Builds the user agent using System properties * diff --git a/src/test/java/com/ibm/watson/developer_cloud/MultiThreadTest.java b/src/test/java/com/ibm/watson/developer_cloud/MultiThreadTest.java index dc700453476..ab12a80ec8f 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/MultiThreadTest.java +++ b/src/test/java/com/ibm/watson/developer_cloud/MultiThreadTest.java @@ -19,7 +19,7 @@ import org.junit.Ignore; import org.junit.Test; -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; +import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation; /** * MultiThread Environment test. @@ -35,14 +35,14 @@ private class LTSenderRunnable implements Runnable { private final Logger log = Logger.getLogger(LTSenderRunnable.class.getName()); /** The service. */ - private final LanguageTranslator service; + private final LanguageTranslation service; /** * Instantiates a new LT sender runnable. * * @param service the service */ - public LTSenderRunnable(LanguageTranslator service) { + public LTSenderRunnable(LanguageTranslation service) { this.service = service; } @@ -75,7 +75,7 @@ public void sendRequest() { } /** The service. */ - private LanguageTranslator service; + private LanguageTranslation service; /* * (non-Javadoc) @@ -86,7 +86,7 @@ public void sendRequest() { @Before public void setUp() throws Exception { super.setUp(); - service = new LanguageTranslator(); + service = new LanguageTranslation(); service.setUsernameAndPassword(getValidProperty("language_translation.username"), getValidProperty("language_translation.password")); service.setEndPoint(getValidProperty("language_translation.url")); diff --git a/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorIT.java b/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorIT.java deleted file mode 100644 index e2ddffcd1d1..00000000000 --- a/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorIT.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - -import static com.ibm.watson.developer_cloud.language_translator.v2.model.Language.ENGLISH; -import static com.ibm.watson.developer_cloud.language_translator.v2.model.Language.SPANISH; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult; - -/** - * Language Translation integration test. - */ -public class LanguageTranslatorIT extends WatsonServiceTest { - - private static final String ENGLISH_TO_SPANISH = "en-es"; - private static final String RESOURCE = "src/test/resources/language_translation/"; - - private LanguageTranslator service; - - private final Map translations = ImmutableMap.of( - "The IBM Watson team is awesome", "El equipo es increĆ­ble IBM Watson", - "Welcome to the cognitive era", "Bienvenido a la era cognitiva"); - private final List texts = ImmutableList.copyOf(translations.keySet()); - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new LanguageTranslator(); - service.setUsernameAndPassword(getValidProperty("language_translation.username"), - getValidProperty("language_translation.password")); - service.setEndPoint(getValidProperty("language_translation.url")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test create and delete model. - */ - @Test - public void testCreateAndDeleteModel() { - CreateModelOptions options = new CreateModelOptions.Builder() - .name("integration-test") - .baseModelId("en-es") - .forcedGlossary(new File(RESOURCE + "glossary.tmx")) - .build(); - - TranslationModel model = null; - try { - model = service.createModel(options).execute(); - Thread.sleep(3000); - assertNotNull(model); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - if (model != null) - service.deleteModel(model.getId()).execute(); - } - } - - /** - * Test Get Identifiable languages. - */ - @Test - public void testGetIdentifiableLanguages() { - final List languages = service.getIdentifiableLanguages().execute(); - assertNotNull(languages); - assertTrue(!languages.isEmpty()); - } - - /** - * Test Get model by id. - */ - @Test - public void testGetModel() { - final TranslationModel model = service.getModel(ENGLISH_TO_SPANISH).execute(); - assertNotNull(model); - } - - /** - * Test Get Models. - */ - @Test - public void testGetModels() { - final List models = service.getModels().execute(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - } - - /** - * Test Identify. - */ - @Test - public void testIdentify() { - final List identifiedLanguages = service.identify(texts.get(0)).execute(); - assertNotNull(identifiedLanguages); - assertFalse(identifiedLanguages.isEmpty()); - } - - /** - * Test translate. - */ - @Test - public void testTranslate() { - for(String text : texts) { - testTranslationResult(text, translations.get(text), service.translate(text, ENGLISH_TO_SPANISH).execute()); - testTranslationResult(text, translations.get(text), service.translate(text, ENGLISH, SPANISH).execute()); - } - } - - /** - * Test translate multiple. - */ - @Test - public void testTranslateMultiple() { - TranslationResult results = service.translate(texts, ENGLISH_TO_SPANISH).execute(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslation()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslation()); - - results = service.translate(texts, ENGLISH, SPANISH).execute(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslation()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslation()); - - } - - private void testTranslationResult(String text, String result, TranslationResult translationResult) { - assertNotNull(translationResult); - assertEquals(translationResult.getWordCount().intValue(), text.split(" ").length); - assertNotNull(translationResult.getTranslations()); - assertNotNull(translationResult.getTranslations().get(0).getTranslation()); - assertEquals(result, translationResult.getTranslations().get(0).getTranslation()); - } - -} diff --git a/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorTest.java b/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorTest.java deleted file mode 100644 index 27e83b428f9..00000000000 --- a/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorTest.java +++ /dev/null @@ -1,304 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.io.FileInputStream; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.Translation; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModels; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult; -import com.ibm.watson.developer_cloud.service.exception.BadRequestException; -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -import okhttp3.mockwebserver.RecordedRequest; - -/** - * The Class LanguageTranslationTest. - */ -public class LanguageTranslatorTest extends WatsonServiceUnitTest { - - private final static String GET_MODELS_PATH = "/v2/models"; - private final static String IDENTIFIABLE_LANGUAGES_PATH = "/v2/identifiable_languages"; - private final static String IDENTITY_PATH = "/v2/identify"; - private final static String LANGUAGE_TRANSLATION_PATH = "/v2/translate"; - private final static String RESOURCE = "src/test/resources/language_translation/"; - private static final Type TYPE_IDENTIFIED_LANGUAGES = - new TypeToken>>() {}.getType(); - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - private final String modelId = "foo-bar"; - private LanguageTranslator service; - - private final Map translations = ImmutableMap.of( - "The IBM Watson team is awesome", "El equipo es increĆ­ble IBM Watson", - "Welcome to the cognitive era", "Bienvenido a la era cognitiva"); - private final List texts = ImmutableList.copyOf(translations.keySet()); - - private TranslationModel model; - private TranslationModels models; - private Map identifiableLanguages; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new LanguageTranslator(); - service.setApiKey(""); - service.setEndPoint(getMockWebServerUrl()); - - // fixtures - String jsonString = getStringFromInputStream(new FileInputStream(RESOURCE + "identifiable_languages.json")); - identifiableLanguages = GSON.fromJson(jsonString, TYPE_IDENTIFIED_LANGUAGES); - - model = loadFixture(RESOURCE + "model.json", TranslationModel.class); - models = loadFixture(RESOURCE + "models.json", TranslationModels.class); - } - - /** - * Test create model with base model null. - */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithBaseModelNull() { - final CreateModelOptions options = new CreateModelOptions.Builder() - .forcedGlossary(new File("src/test/resources/car.png")) - .build(); - service.createModel(options).execute(); - } - - /** - * Test create model with glossary null. - */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithGlossaryNull() { - service.createModel(new CreateModelOptions.Builder().build()).execute(); - } - - /** - * Test delete with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testDeleteWithNull() { - service.deleteModel(null).execute(); - } - - /** - * Test Get Identifiable languages. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetIdentifiableLanguages() throws InterruptedException { - server.enqueue(jsonResponse(identifiableLanguages)); - - final List languages = service.getIdentifiableLanguages().execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(IDENTIFIABLE_LANGUAGES_PATH, request.getPath()); - assertEquals(GSON.toJson(languages), GSON.toJson(identifiableLanguages.get("languages"))); - } - - /** - * Test Get Model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetModel() throws InterruptedException { - server.enqueue(jsonResponse(model)); - - final TranslationModel returnedModel = service.getModel(model.getId()).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(GET_MODELS_PATH + "/" + model.getId(), request.getPath()); - assertEquals(model, returnedModel); - } - - /** - * Test Get Models. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetModels() throws InterruptedException { - server.enqueue(jsonResponse(models)); - - final List modelList = service.getModels().execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(GET_MODELS_PATH, request.getPath()); - assertEquals(GSON.toJson(models.getModels()), GSON.toJson(modelList)); - } - - /** - * Test get model with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testGetModelWithNull() { - final String model = null; - service.getModel(model).execute(); - } - - /** - * Test Identify. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testIdentify() throws InterruptedException { - final List langs = Arrays.asList( - new IdentifiedLanguage("en", 0.877159), - new IdentifiedLanguage("af", 0.0752636) - ); - final Map response = ImmutableMap.of("languages", langs); - final String text = texts.get(0); - - server.enqueue(jsonResponse(response)); - - final List identifiedLanguages = service.identify(text).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(IDENTITY_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(identifiedLanguages); - assertFalse(identifiedLanguages.isEmpty()); - assertNotNull(identifiedLanguages.containsAll(langs)); - } - - /** - * Test translate. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testTranslate() throws InterruptedException { - final String text = texts.get(0); - final Translation t = new Translation(); - t.setTranslation(text); - - final Map response = ImmutableMap.of( - "word_count", 6, - "character_count", 20, - "translations", Collections.singletonList(t) - ); - - final Map requestBody = ImmutableMap.of( - "text", Collections.singleton(text), - "model_id", modelId - ); - - server.enqueue(jsonResponse(response)); - TranslationResult translationResult = service.translate(text, modelId).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(LANGUAGE_TRANSLATION_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(GSON.toJson(requestBody), request.getBody().readUtf8()); - testTranslationResult(text, translationResult); - } - - /** - * Test translate multiple texts. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testTranslateMultiple() throws InterruptedException { - final Translation t1 = new Translation(); - t1.setTranslation(translations.get(texts.get(0))); - final Translation t2 = new Translation(); - t2.setTranslation(translations.get(texts.get(1))); - - final Map response = ImmutableMap.of( - "word_count", 6, - "character_count", 20, - "translations", Arrays.asList(t1, t2) - ); - - final Map requestBody = ImmutableMap.of( - "text", texts, - "model_id", modelId - ); - - server.enqueue(jsonResponse(response)); - TranslationResult translationResult = service.translate(texts, modelId).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(LANGUAGE_TRANSLATION_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(GSON.toJson(requestBody), request.getBody().readUtf8()); - assertEquals(2, translationResult.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), translationResult.getTranslations().get(0).getTranslation()); - assertEquals(translations.get(texts.get(1)), translationResult.getTranslations().get(1).getTranslation()); - } - - /** - * Test Translate with an invalid model. - */ - @Test(expected = BadRequestException.class) - public void testTranslateNotSupported() { - Map response = ImmutableMap.of("error_code", 400, "error message", "error"); - server.enqueue(jsonResponse(response).setResponseCode(400)); - service.translate("X", "FOO-BAR-FOO").execute(); - } - - - /** - * Test translate with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testTranslateWithNull() { - service.translate((String) null, null, null).execute(); - } - - /** - * Test translation result. - * - * @param text the text - * @param translationResult the translation result - */ - private void testTranslationResult(String text, TranslationResult translationResult) { - assertNotNull(translationResult); - assertEquals(translationResult.getWordCount().intValue(), text.split(" ").length); - assertNotNull(translationResult.getTranslations()); - assertNotNull(translationResult.getTranslations().get(0).getTranslation()); - } -} diff --git a/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java b/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java index bbacc41b015..2a320465748 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java @@ -326,7 +326,7 @@ public void testUploadAndDeleteSolrClusterConfigurationZip() { /** * Test solr cluster resize. * - * @throws InterruptedException + * @throws InterruptedException the interrupted exception */ @Test @Ignore diff --git a/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankTest.java b/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankTest.java index 7aefec391b7..fce584e1b18 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankTest.java +++ b/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankTest.java @@ -1,11 +1,11 @@ -/** - * Copyright 2016 IBM Corp. All Rights Reserved. - * +/* + * Copyright 2015 IBM Corp. All Rights Reserved. + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under @@ -28,8 +28,7 @@ import okhttp3.mockwebserver.RecordedRequest; /** - * - * Retrieve and Rank unit test + * Retrieve and Rank unit test. */ public class RetrieveAndRankTest extends WatsonServiceUnitTest { @@ -55,10 +54,10 @@ public void setUp() throws Exception { } /** - * Test cluster resize - * - * @throws FileNotFoundException - * @throws InterruptedException + * Test cluster resize. + * + * @throws FileNotFoundException the file not found exception + * @throws InterruptedException the interrupted exception */ @Test public void testClusterResize() throws FileNotFoundException, InterruptedException { diff --git a/src/test/java/com/ibm/watson/developer_cloud/service/GenericServiceTest.java b/src/test/java/com/ibm/watson/developer_cloud/service/GenericServiceTest.java index a591228e50c..5ac270700ed 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/service/GenericServiceTest.java +++ b/src/test/java/com/ibm/watson/developer_cloud/service/GenericServiceTest.java @@ -27,6 +27,9 @@ import java.util.Map; import java.util.concurrent.ExecutionException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + import org.junit.AssumptionViolatedException; import org.junit.Before; import org.junit.Test; @@ -47,7 +50,6 @@ import com.ibm.watson.developer_cloud.http.HttpHeaders; import com.ibm.watson.developer_cloud.http.HttpMediaType; import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation; -import com.ibm.watson.developer_cloud.language_translator.v2.LanguageTranslator; import com.ibm.watson.developer_cloud.natural_language_classifier.v1.NaturalLanguageClassifier; import com.ibm.watson.developer_cloud.personality_insights.v2.PersonalityInsights; import com.ibm.watson.developer_cloud.personality_insights.v2.model.Profile; @@ -79,9 +81,6 @@ import jersey.repackaged.jsr166e.CompletableFuture; import okhttp3.Credentials; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.RecordedRequest; @@ -124,7 +123,6 @@ public void testConstructors() { checkApiKey(new ConversationService(ConversationService.VERSION_DATE_2016_05_19, u, p), key); checkApiKey(new DialogService(u, p), key); checkApiKey(new DocumentConversion(DocumentConversion.VERSION_DATE_2015_12_01, u, p), key); - checkApiKey(new LanguageTranslator(u, p), key); checkApiKey(new LanguageTranslation(u, p), key); checkApiKey(new NaturalLanguageClassifier(u, p), key); checkApiKey(new PersonalityInsights(u, p), key); From e327f0915e9a82e4520667b78178f0bd8da6bd9b Mon Sep 17 00:00:00 2001 From: German Attanasio Ruiz Date: Mon, 1 Aug 2016 15:46:27 -0400 Subject: [PATCH 2/2] [ci skip] :unamused: update language translation readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 198651a4e8e..d7ea31a6cec 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ APIs and SDKs that use cognitive computing to solve complex problems. * [Conversation](#conversation) * [Dialog](#dialog) * [Document Conversion](#document-conversion) - * [Language Translator](#language-translator) + * [Language Translation](#language-translation) * [Natural Language Classifier](#natural-language-classifier) * [Personality Insights](#personality-insights) * [Relationship Extraction](#relationship-extraction) @@ -302,12 +302,12 @@ Answers htmlToAnswers = service.convertDocumentToAnswer(doc).execute(); System.out.println(htmlToAnswers); ``` -### Language Translator +### Language Translation Select a domain, then identify or select the language of text, and then translate the text from one supported language to another. -Example: Translate 'hello' from English to Spanish using the [Language Translator][language_translator] service. +Example: Translate 'hello' from English to Spanish using the [Language Translator][language_translation] service. ```java -LanguageTranslator service = new LanguageTranslator(); +LanguageTranslator service = new LanguageTranslation(); service.setUsernameAndPassword("", ""); TranslationResult translationResult = service.translate( @@ -619,7 +619,7 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md). [personality_insights]: http://www.ibm.com/watson/developercloud/doc/personality-insights/ [document_conversion]: http://www.ibm.com/watson/developercloud/doc/document-conversion/ [relationship_extraction]: http://www.ibm.com/watson/developercloud/doc/sireapi/ -[language_translator]: http://www.ibm.com/watson/developercloud/doc/language-translation/ +[language_translation]: http://www.ibm.com/watson/developercloud/doc/language-translation/ [visual_recognition]: http://www.ibm.com/watson/developercloud/doc/visual-recognition/ [tradeoff_analytics]: http://www.ibm.com/watson/developercloud/doc/tradeoff-analytics/ [text_to_speech]: http://www.ibm.com/watson/developercloud/doc/text-to-speech/