Search in sources :

Example 1 with CategoriesResult

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

the class NaturalLanguageUnderstandingIT method analyzeTextForCategoriesIsSuccessful.

/**
 * Analyze input text for categories.
 *
 * @throws Exception the exception
 */
@Test
public void analyzeTextForCategoriesIsSuccessful() throws Exception {
    Features features = new Features.Builder().categories(new CategoriesOptions()).build();
    AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build();
    AnalysisResults results = service.analyze(parameters).execute();
    assertNotNull(results);
    assertEquals(results.getAnalyzedText(), text);
    assertEquals(results.getLanguage(), "en");
    assertNotNull(results.getCategories());
    for (CategoriesResult result : results.getCategories()) {
        assertNotNull(result.getLabel());
        assertNotNull(result.getScore());
    }
}
Also used : CategoriesOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesOptions) AnalyzeOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions) AnalysisResults(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults) CategoriesResult(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesResult) Features(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 AnalysisResults (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults)1 AnalyzeOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions)1 CategoriesOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesOptions)1 CategoriesResult (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesResult)1 Features (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features)1 Test (org.junit.Test)1