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());
}
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);
}
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());
}
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;
}
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());
}
Aggregations