Search in sources :

Example 26 with Words

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words 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());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) Words(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 27 with Words

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.

the class SpeechToText method listWords.

/**
 * Lists all custom words from a custom language model.
 *
 * Lists information about custom words from a custom language model. You can list all words from the custom model's
 * words resource, only custom words that were added or modified by the user, or only out-of-vocabulary (OOV) words
 * that were extracted from corpora. You can also indicate the order in which the service is to return words; by
 * default, words are listed in ascending alphabetical order. You must use credentials for the instance of the service
 * that owns a model to query information about its words.
 *
 * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Words}
 */
public ServiceCall<Words> listWords(ListWordsOptions listWordsOptions) {
    Validator.notNull(listWordsOptions, "listWordsOptions cannot be null");
    String[] pathSegments = { "v1/customizations", "words" };
    String[] pathParameters = { listWordsOptions.customizationId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    if (listWordsOptions.wordType() != null) {
        builder.query("word_type", listWordsOptions.wordType());
    }
    if (listWordsOptions.sort() != null) {
        builder.query("sort", listWordsOptions.sort());
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Words.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) Words(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)

Aggregations

Test (org.junit.Test)20 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)13 Words (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)12 ListWordsOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions)11 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)9 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)7 Words (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words)7 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 AddWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions)6 ListWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions)6 MockResponse (okhttp3.mockwebserver.MockResponse)6 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)5 Ignore (org.junit.Ignore)5 JsonObject (com.google.gson.JsonObject)4 JsonParser (com.google.gson.JsonParser)4 Translation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation)4 VoiceModel (com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel)4 FileInputStream (java.io.FileInputStream)4 ByteString (okio.ByteString)4 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)3