Search in sources :

Example 11 with ListWordsOptions

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

the class SpeechToTextIT method testGetWordsThreeTypeSort.

/**
 * Test list words with type all and count sort.
 */
@Test
@Ignore
public void testGetWordsThreeTypeSort() {
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(customizationId).wordType(ListWordsOptions.WordType.ALL).sort(ListWordsOptions.Sort.COUNT).build();
    Words result = service.listWords(listOptions).execute();
    assertNotNull(result);
    assertTrue(!result.getWords().isEmpty());
}
Also used : Words(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 12 with ListWordsOptions

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

the class SpeechToTextIT method testGetWordsThreeSort.

/**
 * Test list words with alphabetical sort.
 */
@Test
@Ignore
public void testGetWordsThreeSort() {
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(customizationId).sort(ListWordsOptions.Sort.ALPHABETICAL).build();
    Words result = service.listWords(listOptions).execute();
    assertNotNull(result);
    assertTrue(!result.getWords().isEmpty());
}
Also used : Words(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 13 with ListWordsOptions

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

the class SpeechToTextIT method testListWordsCustomizationId.

/**
 * Test list words with just a customization ID.
 */
@Test
@Ignore
public void testListWordsCustomizationId() {
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(customizationId).build();
    Words result = service.listWords(listOptions).execute();
    assertNotNull(result);
    assertTrue(!result.getWords().isEmpty());
}
Also used : Words(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 14 with ListWordsOptions

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

the class SpeechToTextTest method testListWords.

/**
 * Test list words.
 *
 * @throws InterruptedException the interrupted exception
 * @throws FileNotFoundException the file not found exception
 */
@Test
public void testListWords() throws InterruptedException, FileNotFoundException {
    String id = "foo";
    String wordsAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/words.json"));
    JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject();
    server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordsAsStr));
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(id).build();
    Words result = service.listWords(listOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals("GET", request.getMethod());
    assertEquals(String.format(PATH_WORDS, id), request.getPath());
    assertEquals(words.get("words"), GSON.toJsonTree(result.getWords()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Words(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions) JsonObject(com.google.gson.JsonObject) ByteString(okio.ByteString) FileInputStream(java.io.FileInputStream) JsonParser(com.google.gson.JsonParser) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 15 with ListWordsOptions

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

the class SpeechToTextTest method testListWordsSort.

/**
 * Test list words with sort order alphabetical.
 *
 * @throws InterruptedException the interrupted exception
 * @throws FileNotFoundException the file not found exception
 */
@Test
public void testListWordsSort() throws InterruptedException, FileNotFoundException {
    String id = "foo";
    String wordsAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/words.json"));
    JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject();
    server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordsAsStr));
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(id).sort(ListWordsOptions.Sort.ALPHABETICAL).build();
    Words result = service.listWords(listOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals("GET", request.getMethod());
    assertEquals(String.format(PATH_WORDS, id) + "?sort=alphabetical", request.getPath());
    assertEquals(words.get("words"), GSON.toJsonTree(result.getWords()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Words(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions) JsonObject(com.google.gson.JsonObject) ByteString(okio.ByteString) FileInputStream(java.io.FileInputStream) JsonParser(com.google.gson.JsonParser) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 ListWordsOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions)11 Words (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)11 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)10 Words (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words)7 ListWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions)6 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)6 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)5 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)5 Ignore (org.junit.Ignore)5 JsonObject (com.google.gson.JsonObject)4 JsonParser (com.google.gson.JsonParser)4 FileInputStream (java.io.FileInputStream)4 MockResponse (okhttp3.mockwebserver.MockResponse)4 ByteString (okio.ByteString)4 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)3 AddWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions)3 File (java.io.File)3 AddCorpusOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddCorpusOptions)2 AddWordOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions)2