use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testGetWord.
/**
* Test get word.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testGetWord() throws InterruptedException {
final Word expected = instantiateWords().get(0);
server.enqueue(jsonResponse(ImmutableMap.of(TRANSLATION, expected.getTranslation())));
GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(CUSTOMIZATION_ID).word(expected.getWord()).build();
final Translation result = service.getWord(getOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected.getWord(), request.getPath());
assertEquals("GET", request.getMethod());
assertEquals(expected.getTranslation(), result.getTranslation());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testAddWords.
/**
* Test add words.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testAddWords() throws InterruptedException {
final List<Word> expected = instantiateWords();
server.enqueue(new MockResponse().setResponseCode(201));
AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(CUSTOMIZATION_ID).words(expected).build();
service.addWords(addOptions).execute();
RecordedRequest request = server.takeRequest();
assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath());
assertEquals("POST", request.getMethod());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testListWords.
/**
* Test list words.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testListWords() throws InterruptedException {
final List<Word> expected = instantiateWords();
server.enqueue(jsonResponse(ImmutableMap.of(WORDS, expected)));
ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(CUSTOMIZATION_ID).build();
final Words result = service.listWords(listOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath());
assertEquals("GET", request.getMethod());
assertEquals(expected, result.getWords());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method instantiateWords.
private static List<Word> instantiateWords() {
Word word = new Word();
word.setWord("hodor");
word.setTranslation("hold the door");
return ImmutableList.of(word);
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class SpeechToText method getWord.
/**
* Lists a custom word from a custom language model.
*
* Lists information about a custom word from a custom language model. You must use credentials for the instance of
* the service that owns a model to query information about its words.
*
* @param getWordOptions the {@link GetWordOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Word}
*/
public ServiceCall<Word> getWord(GetWordOptions getWordOptions) {
Validator.notNull(getWordOptions, "getWordOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.wordName() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Word.class));
}
Aggregations