use of com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EntitiesResult in project java-sdk by watson-developer-cloud.
the class NaturalLanguageUnderstandingIT method analyzeHtmlForDisambiguationIsSuccessful.
/**
* Analyze html for disambiguation.
*
* @throws Exception the exception
*/
@Test
public void analyzeHtmlForDisambiguationIsSuccessful() throws Exception {
EntitiesOptions entities = new EntitiesOptions.Builder().sentiment(true).limit(1).build();
Features features = new Features.Builder().entities(entities).build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder().url("www.cnn.com").features(features).build();
AnalysisResults results = service.analyze(parameters).execute();
assertNotNull(results);
assertEquals(results.getLanguage(), "en");
assertNotNull(results.getEntities());
assertTrue(results.getEntities().size() == 1);
for (EntitiesResult result : results.getEntities()) {
assertNotNull(result.getDisambiguation());
assertEquals(result.getDisambiguation().getName(), "CNN");
assertEquals(result.getDisambiguation().getDbpediaResource(), "http://dbpedia.org/resource/CNN");
assertNotNull(result.getDisambiguation().getSubtype());
assertTrue(result.getDisambiguation().getSubtype().size() > 0);
}
}
use of com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EntitiesResult in project java-sdk by watson-developer-cloud.
the class NaturalLanguageUnderstandingIT method analyzeTextForEntitiesIsSuccessful.
/**
* Analyze input text for entities.
*
* @throws Exception the exception
*/
@Test
public void analyzeTextForEntitiesIsSuccessful() throws Exception {
String text = "In 2009, Elliot Turner launched AlchemyAPI to process the written word, with all of its quirks " + "and nuances, and got immediate traction.";
EntitiesOptions entities = new EntitiesOptions.Builder().limit(2).sentiment(true).build();
Features features = new Features.Builder().entities(entities).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.getEntities());
assertTrue(results.getEntities().size() == 2);
for (EntitiesResult result : results.getEntities()) {
assertNotNull(result.getCount());
assertNotNull(result.getRelevance());
assertNotNull(result.getText());
assertNotNull(result.getType());
assertNotNull(result.getSentiment());
}
}
Aggregations