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