diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DisambiguationResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DisambiguationResult.java new file mode 100644 index 00000000000..a0ca461b172 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DisambiguationResult.java @@ -0,0 +1,85 @@ +/* + * Copyright 2017 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Disambiguation information for the entity. + */ +public class DisambiguationResult extends GenericModel { + + /** Common entity name. */ + private String name; + @SerializedName("dbpedia_resource") + private String dbpediaResource; + /** Entity subtype information. */ + private List subtype; + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the dbpediaResource. + * + * @return the dbpediaResource + */ + public String getDbpediaResource() { + return dbpediaResource; + } + + /** + * Gets the subtype. + * + * @return the subtype + */ + public List getSubtype() { + return subtype; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(final String name) { + this.name = name; + } + + /** + * Sets the dbpediaResource. + * + * @param dbpediaResource the new dbpediaResource + */ + public void setDbpediaResource(final String dbpediaResource) { + this.dbpediaResource = dbpediaResource; + } + + /** + * Sets the subtype. + * + * @param subtype the new subtype + */ + public void setSubtype(final List subtype) { + this.subtype = subtype; + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java index 5a4aedb962b..2943d04b987 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java @@ -27,10 +27,12 @@ public class EntitiesResult extends GenericModel { private Integer count; /** The name of the entity. */ private String text; - /** Emotion analysis results for the entity, enabled with the \"emotion\" option. */ + /** Emotion analysis results for the entity, enabled with the "emotion" option. */ private EmotionScores emotion; - /** Sentiment analysis results for the entity, enabled with the \"sentiment\" option. */ + /** Sentiment analysis results for the entity, enabled with the "sentiment" option. */ private FeatureSentimentResults sentiment; + /** Disambiguation information for the entity. */ + private DisambiguationResult disambiguation; /** * Gets the type. @@ -86,6 +88,15 @@ public FeatureSentimentResults getSentiment() { return sentiment; } + /** + * Gets the disambiguation. + * + * @return the disambiguation + */ + public DisambiguationResult getDisambiguation() { + return disambiguation; + } + /** * Sets the type. * @@ -140,4 +151,12 @@ public void setSentiment(final FeatureSentimentResults sentiment) { this.sentiment = sentiment; } + /** + * Sets the disambiguation. + * + * @param disambiguation the new disambiguation + */ + public void setDisambiguation(final DisambiguationResult disambiguation) { + this.disambiguation = disambiguation; + } } diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java b/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java index 85fc1d58f1c..213418121ba 100644 --- a/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java +++ b/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java @@ -495,4 +495,31 @@ public void analyzeTextForCategoriesIsSuccessful() throws Exception { assertNotNull(result.getScore()); } } + + /** + * 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); + } + } }