use of com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.KeywordsResult in project java-sdk by watson-developer-cloud.
the class NaturalLanguageUnderstandingIT method analyzeTextForKeywordsIsSuccessful.
/**
* Analyze input text for keywords.
*
* @throws Exception the exception
*/
@Test
public void analyzeTextForKeywordsIsSuccessful() throws Exception {
KeywordsOptions keywords = new KeywordsOptions.Builder().sentiment(true).build();
Features features = new Features.Builder().keywords(keywords).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);
assertNotNull(results.getKeywords());
for (KeywordsResult result : results.getKeywords()) {
assertNotNull(result.getRelevance());
assertNotNull(result.getText());
assertNotNull(result.getSentiment());
}
}
Aggregations