Search in sources :

Example 11 with Word

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

the class CustomizationsIT method testDeleteWord.

/**
 * Test delete word with string.
 */
@Test
public void testDeleteWord() {
    model = createVoiceModel();
    final Word expected = instantiateWords().get(0);
    AddWordOptions addOptions = new AddWordOptions.Builder().word(expected.getWord()).translation(expected.getTranslation()).customizationId(model.getCustomizationId()).build();
    service.addWord(addOptions).execute();
    DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder().customizationId(model.getCustomizationId()).word(expected.getWord()).build();
    service.deleteWord(deleteOptions).execute();
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
    final Words results = service.listWords(listOptions).execute();
    assertEquals(0, results.getWords().size());
}
Also used : AddWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions) 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) DeleteWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 12 with Word

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

the class CustomizationsIT method instantiateWordsJapanese.

private List<Word> instantiateWordsJapanese() {
    Word word1 = new Word();
    word1.setWord("hodor");
    word1.setTranslation("hold the door");
    word1.setPartOfSpeech(Word.PartOfSpeech.JOSI);
    Word word2 = new Word();
    word2.setWord("clodor");
    word2.setTranslation("close the door");
    word2.setPartOfSpeech(Word.PartOfSpeech.HOKA);
    return ImmutableList.of(word1, word2);
}
Also used : Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)

Example 13 with Word

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

the class CustomizationsIT method testAddWord.

/**
 * Test add word.
 */
@Test
public void testAddWord() {
    model = createVoiceModel();
    final Word expected = instantiateWords().get(0);
    AddWordOptions addOptions = new AddWordOptions.Builder().word(expected.getWord()).translation(expected.getTranslation()).customizationId(model.getCustomizationId()).build();
    service.addWord(addOptions).execute();
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
    final Words results = service.listWords(listOptions).execute();
    assertEquals(1, results.getWords().size());
    final Word result = results.getWords().get(0);
    assertEquals(expected, result);
    assertEquals(expected.getWord(), result.getWord());
    assertEquals(expected.getTranslation(), result.getTranslation());
}
Also used : AddWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions) 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) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 14 with Word

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

the class CustomizationsTest method instantiateWord.

private static Word instantiateWord() {
    Word word = new Word();
    word.setWord("hodor");
    word.setTranslation("hold the door");
    return word;
}
Also used : Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)

Example 15 with Word

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

the class CustomizationsTest method testAddWord.

/**
 * Test add word.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testAddWord() throws InterruptedException {
    final Word expected = instantiateWord();
    server.enqueue(new MockResponse().setResponseCode(201));
    AddWordOptions addOptions = new AddWordOptions.Builder().customizationId(CUSTOMIZATION_ID).word(expected.getWord()).translation(expected.getTranslation()).build();
    service.addWord(addOptions).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(String.format(WORD_PATH, CUSTOMIZATION_ID, expected.getWord()), request.getPath());
    assertEquals("PUT", request.getMethod());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) AddWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions) Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)19 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)16 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)10 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)10 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)9 MockResponse (okhttp3.mockwebserver.MockResponse)8 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 Words (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words)6 ByteString (okio.ByteString)6 ListWordsOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions)5 Word (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word)5 Words (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)5 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)5 JsonObject (com.google.gson.JsonObject)4 GetWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions)4 Translation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation)4 JsonParser (com.google.gson.JsonParser)3 AddWordOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions)3 CustomWord (com.ibm.watson.developer_cloud.speech_to_text.v1.model.CustomWord)3