use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testDeleteCorpus.
/**
* Test delete corpus.
*
* @throws InterruptedException the interrupted exception
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testDeleteCorpus() throws InterruptedException, FileNotFoundException {
String id = "foo";
String corpus = "cName";
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
DeleteCorpusOptions deleteOptions = new DeleteCorpusOptions.Builder().customizationId(id).corpusName(corpus).build();
service.deleteCorpus(deleteOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("DELETE", request.getMethod());
assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath());
}
use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testGetCorpus.
/**
* Test get corpus.
*
* @throws InterruptedException the interrupted exception
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testGetCorpus() throws InterruptedException, FileNotFoundException {
String id = "foo";
String corpus = "cName";
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
GetCorpusOptions getOptions = new GetCorpusOptions.Builder().customizationId(id).corpusName(corpus).build();
service.getCorpus(getOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("GET", request.getMethod());
assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath());
}
use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testAddCorpus.
/**
* Test add corpus.
*
* @throws InterruptedException the interrupted exception
* @throws IOException the IO exception
*/
@Test
public void testAddCorpus() throws InterruptedException, IOException {
String id = "foo";
String corpusName = "cName";
File corpusFile = new File("src/test/resources/speech_to_text/corpus-text.txt");
String corpusFileText = new String(Files.readAllBytes(Paths.get(corpusFile.toURI())));
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
AddCorpusOptions addOptions = new AddCorpusOptions.Builder().customizationId(id).corpusName(corpusName).corpusFile(corpusFile).corpusFileContentType(HttpMediaType.TEXT_PLAIN).allowOverwrite(true).build();
service.addCorpus(addOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("POST", request.getMethod());
assertEquals(String.format(PATH_CORPUS, id, corpusName) + "?allow_overwrite=true", request.getPath());
assertTrue(request.getBody().readUtf8().contains(corpusFileText));
}
use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus in project java-sdk by watson-developer-cloud.
the class SpeechToText method getCorpus.
/**
* Lists information about a corpus for a custom language model.
*
* Lists information about a corpus from a custom language model. The information includes the total number of words
* and out-of-vocabulary (OOV) words, name, and status of the corpus. You must use credentials for the instance of the
* service that owns a model to list its corpora.
*
* @param getCorpusOptions the {@link GetCorpusOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Corpus}
*/
public ServiceCall<Corpus> getCorpus(GetCorpusOptions getCorpusOptions) {
Validator.notNull(getCorpusOptions, "getCorpusOptions cannot be null");
String[] pathSegments = { "v1/customizations", "corpora" };
String[] pathParameters = { getCorpusOptions.customizationId(), getCorpusOptions.corpusName() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Corpus.class));
}
Aggregations