Search in sources :

Example 6 with ConceptsOptions

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

the class NaturalLanguageUnderstandingTest method testAnalyze.

/**
 * Test analyze.
 *
 * @throws InterruptedException the interrupted exception
 * @throws FileNotFoundException
 */
@Test
public void testAnalyze() throws InterruptedException, FileNotFoundException {
    String testHtmlFileName = RESOURCE + "testArticle.html";
    String html = getStringFromInputStream(new FileInputStream(testHtmlFileName));
    ConceptsOptions concepts = new ConceptsOptions.Builder().limit(5).build();
    assertEquals(concepts.limit(), 5, 0);
    concepts.newBuilder();
    Features features = new Features.Builder().concepts(concepts).build();
    AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).build();
    server.enqueue(jsonResponse(analyzeResults));
    final AnalysisResults response = service.analyze(parameters).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(ANALYZE_PATH, request.getPath());
    assertEquals("POST", request.getMethod());
    assertEquals(analyzeResults, response);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) AnalyzeOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions) AnalysisResults(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults) ConceptsOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ConceptsOptions) Features(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features) FileInputStream(java.io.FileInputStream) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

AnalysisResults (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults)6 AnalyzeOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions)6 ConceptsOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ConceptsOptions)6 Features (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features)6 Test (org.junit.Test)6 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)5 FileInputStream (java.io.FileInputStream)3 ConceptsResult (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ConceptsResult)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1