From 2fcbb61c584767627ff4f543485dee17f9087bca Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Thu, 7 Dec 2017 11:05:11 -0500 Subject: [PATCH 1/9] Make sure Travis updates the GitHub pages on tagged commits (#830) * Make sure Travis updates the GitHub pages on tagged commits * [Gradle Release Plugin] - new version commit: 'java-sdk-4.0.2-SNAPSHOT'. * Fix change to project version --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7cbc57d2bac..404a58eac3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,7 @@ deploy: on: repo: watson-developer-cloud/java-sdk jdk: oraclejdk7 + tags: true - provider: script script: .utility/deploy.sh From fa1a879b49f81828ead00001ee8a08426a24a0c1 Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Tue, 12 Dec 2017 11:57:12 -0500 Subject: [PATCH 2/9] Add new NLU-based enrichment models --- .../discovery/v1/model/Enrichment.java | 5 +- .../discovery/v1/model/EnrichmentOptions.java | 207 +----------------- .../v1/model/NluEnrichmentCategories.java | 22 ++ .../v1/model/NluEnrichmentEmotion.java | 66 ++++++ .../v1/model/NluEnrichmentEntities.java | 174 +++++++++++++++ .../v1/model/NluEnrichmentFeatures.java | 171 +++++++++++++++ .../v1/model/NluEnrichmentKeywords.java | 85 +++++++ .../v1/model/NluEnrichmentRelations.java | 44 ++++ .../v1/model/NluEnrichmentSemanticRoles.java | 85 +++++++ .../v1/model/NluEnrichmentSentiment.java | 66 ++++++ 10 files changed, 726 insertions(+), 199 deletions(-) create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java create mode 100644 discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Enrichment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Enrichment.java index b71fff25eb5..87e129033aa 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Enrichment.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Enrichment.java @@ -81,7 +81,8 @@ public Boolean isOverwrite() { /** * Gets the enrichmentName. * - * Name of the enrichment service to call. Currently the only valid value is `alchemy_language`. + * Name of the enrichment service to call. Currently the only valid value is `natural_language_understanding`. + * Previous API versions also supported `alchemy_language`. * * @return the enrichmentName */ @@ -104,7 +105,7 @@ public Boolean isIgnoreDownstreamErrors() { /** * Gets the options. * - * A list of options specific to the enrichment + * A list of options specific to the enrichment. * * @return the options */ diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java index b8f4fe44a29..530d4ae5f8b 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java @@ -12,8 +12,6 @@ */ package com.ibm.watson.developer_cloud.discovery.v1.model; -import java.util.List; - import com.ibm.watson.developer_cloud.service.model.GenericModel; /** @@ -21,210 +19,25 @@ */ public class EnrichmentOptions extends GenericModel { - /** - * If provided, then do not attempt to detect the language of the input document. Instead, assume the language is the - * one specified in this field. You can set this property to work around `unsupported-text-language` errors. Supported - * languages include English, German, French, Italian, Portuguese, Russian, Spanish and Swedish. Supported language - * codes are the ISO-639-1, ISO-639-2, ISO-639-3, and the plain english name of the language (for example "russian"). - */ - public interface Language { - /** english. */ - String ENGLISH = "english"; - /** german. */ - String GERMAN = "german"; - /** french. */ - String FRENCH = "french"; - /** italian. */ - String ITALIAN = "italian"; - /** portuguese. */ - String PORTUGUESE = "portuguese"; - /** russian. */ - String RUSSIAN = "russian"; - /** spanish. */ - String SPANISH = "spanish"; - /** swedish. */ - String SWEDISH = "swedish"; - /** en. */ - String EN = "en"; - /** eng. */ - String ENG = "eng"; - /** de. */ - String DE = "de"; - /** ger. */ - String GER = "ger"; - /** deu. */ - String DEU = "deu"; - /** fr. */ - String FR = "fr"; - /** fre. */ - String FRE = "fre"; - /** fra. */ - String FRA = "fra"; - /** it. */ - String IT = "it"; - /** ita. */ - String ITA = "ita"; - /** pt. */ - String PT = "pt"; - /** por. */ - String POR = "por"; - /** ru. */ - String RU = "ru"; - /** rus. */ - String RUS = "rus"; - /** es. */ - String ES = "es"; - /** spa. */ - String SPA = "spa"; - /** sv. */ - String SV = "sv"; - /** swe. */ - String SWE = "swe"; - } - - private List extract; - private Boolean sentiment; - private Boolean quotations; - private Boolean showSourceText; - private Boolean hierarchicalTypedRelations; - private String model; - private String language; - - /** - * Gets the extract. - * - * A comma-separated list of analyses that will be applied when using the `alchemy_language` enrichment. See the - * service documentation for details on each extract option. Possible values include: * entity * keyword * taxonomy * - * concept * relation * doc-sentiment * doc-emotion * typed-rels - * - * @return the extract - */ - public List getExtract() { - return extract; - } - - /** - * Gets the sentiment. - * - * @return the sentiment - */ - public Boolean isSentiment() { - return sentiment; - } - - /** - * Gets the quotations. - * - * @return the quotations - */ - public Boolean isQuotations() { - return quotations; - } - - /** - * Gets the showSourceText. - * - * @return the showSourceText - */ - public Boolean isShowSourceText() { - return showSourceText; - } + private NluEnrichmentFeatures features; /** - * Gets the hierarchicalTypedRelations. + * Gets the features. * - * @return the hierarchicalTypedRelations - */ - public Boolean isHierarchicalTypedRelations() { - return hierarchicalTypedRelations; - } - - /** - * Gets the model. - * - * Required when using the `typed-rel` extract option. Should be set to the ID of a previously published custom Watson - * Knowledge Studio model. - * - * @return the model - */ - public String getModel() { - return model; - } - - /** - * Gets the language. - * - * If provided, then do not attempt to detect the language of the input document. Instead, assume the language is the - * one specified in this field. You can set this property to work around `unsupported-text-language` errors. Supported - * languages include English, German, French, Italian, Portuguese, Russian, Spanish and Swedish. Supported language - * codes are the ISO-639-1, ISO-639-2, ISO-639-3, and the plain english name of the language (for example "russian"). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Sets the extract. - * - * @param extract the new extract - */ - public void setExtract(final List extract) { - this.extract = extract; - } - - /** - * Sets the sentiment. - * - * @param sentiment the new sentiment - */ - public void setSentiment(final Boolean sentiment) { - this.sentiment = sentiment; - } - - /** - * Sets the quotations. - * - * @param quotations the new quotations - */ - public void setQuotations(final Boolean quotations) { - this.quotations = quotations; - } - - /** - * Sets the showSourceText. - * - * @param showSourceText the new showSourceText - */ - public void setShowSourceText(final Boolean showSourceText) { - this.showSourceText = showSourceText; - } - - /** - * Sets the hierarchicalTypedRelations. - * - * @param hierarchicalTypedRelations the new hierarchicalTypedRelations - */ - public void setHierarchicalTypedRelations(final Boolean hierarchicalTypedRelations) { - this.hierarchicalTypedRelations = hierarchicalTypedRelations; - } - - /** - * Sets the model. + * An object representing the enrichment features that will be applied to the specified field. * - * @param model the new model + * @return the features */ - public void setModel(final String model) { - this.model = model; + public NluEnrichmentFeatures getFeatures() { + return features; } /** - * Sets the language. + * Sets the features. * - * @param language the new language + * @param features the new features */ - public void setLanguage(final String language) { - this.language = language; + public void setFeatures(final NluEnrichmentFeatures features) { + this.features = features; } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java new file mode 100644 index 00000000000..8e75845e131 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java @@ -0,0 +1,22 @@ +/* + * 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.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.DynamicModel; + +/** + * An object that indicates the Categories enrichment will be applied to the specified field. + */ +public class NluEnrichmentCategories extends DynamicModel { + +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java new file mode 100644 index 00000000000..c0cfd179c99 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java @@ -0,0 +1,66 @@ +/* + * 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.discovery.v1.model; + +import java.util.List; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object specifying the emotion detection enrichment and related parameters. + */ +public class NluEnrichmentEmotion extends GenericModel { + + private Boolean document; + private List targets; + + /** + * Gets the document. + * + * When `true`, emotion detection is performed on the entire field. + * + * @return the document + */ + public Boolean isDocument() { + return document; + } + + /** + * Gets the targets. + * + * A comma-separated list of target strings that will have any associated emotions detected. + * + * @return the targets + */ + public List getTargets() { + return targets; + } + + /** + * Sets the document. + * + * @param document the new document + */ + public void setDocument(final Boolean document) { + this.document = document; + } + + /** + * Sets the targets. + * + * @param targets the new targets + */ + public void setTargets(final List targets) { + this.targets = targets; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java new file mode 100644 index 00000000000..340aaf5861c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java @@ -0,0 +1,174 @@ +/* + * 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.discovery.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object speficying the Entities enrichment and related parameters. + */ +public class NluEnrichmentEntities extends GenericModel { + + private Boolean sentiment; + private Boolean emotion; + private Long limit; + private Boolean mentions; + @SerializedName("mention_types") + private Boolean mentionTypes; + @SerializedName("sentence_location") + private Boolean sentenceLocation; + private String model; + + /** + * Gets the sentiment. + * + * When `true`, sentiment analysis of entities will be performed on the specified field. + * + * @return the sentiment + */ + public Boolean isSentiment() { + return sentiment; + } + + /** + * Gets the emotion. + * + * When `true`, emotion detection of entities will be performed on the specified field. + * + * @return the emotion + */ + public Boolean isEmotion() { + return emotion; + } + + /** + * Gets the limit. + * + * The maximum number of entities to extract for each instance of the specified field. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Gets the mentions. + * + * When `true`, the number of mentions of each identified entity is recorded. The default is `false`. + * + * @return the mentions + */ + public Boolean isMentions() { + return mentions; + } + + /** + * Gets the mentionTypes. + * + * When `true`, the types of mentions for each idetifieid entity is recorded. The default is `false`. + * + * @return the mentionTypes + */ + public Boolean isMentionTypes() { + return mentionTypes; + } + + /** + * Gets the sentenceLocation. + * + * When `true`, a list of sentence locations for each instance of each identified entity is recorded. The default is + * `false`. + * + * @return the sentenceLocation + */ + public Boolean isSentenceLocation() { + return sentenceLocation; + } + + /** + * Gets the model. + * + * The enrichement model to use with entity extraction. May be a custom model provided by Watson Knowledge Studio, the + * public model for use with Knowledge Graph `en-news`, or the default public model `alchemy`. + * + * @return the model + */ + public String getModel() { + return model; + } + + /** + * Sets the sentiment. + * + * @param sentiment the new sentiment + */ + public void setSentiment(final Boolean sentiment) { + this.sentiment = sentiment; + } + + /** + * Sets the emotion. + * + * @param emotion the new emotion + */ + public void setEmotion(final Boolean emotion) { + this.emotion = emotion; + } + + /** + * Sets the limit. + * + * @param limit the new limit + */ + public void setLimit(final long limit) { + this.limit = limit; + } + + /** + * Sets the mentions. + * + * @param mentions the new mentions + */ + public void setMentions(final Boolean mentions) { + this.mentions = mentions; + } + + /** + * Sets the mentionTypes. + * + * @param mentionTypes the new mentionTypes + */ + public void setMentionTypes(final Boolean mentionTypes) { + this.mentionTypes = mentionTypes; + } + + /** + * Sets the sentenceLocation. + * + * @param sentenceLocation the new sentenceLocation + */ + public void setSentenceLocation(final Boolean sentenceLocation) { + this.sentenceLocation = sentenceLocation; + } + + /** + * Sets the model. + * + * @param model the new model + */ + public void setModel(final String model) { + this.model = model; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java new file mode 100644 index 00000000000..4baa3ce429c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java @@ -0,0 +1,171 @@ +/* + * 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.discovery.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * NluEnrichmentFeatures. + */ +public class NluEnrichmentFeatures extends GenericModel { + + private NluEnrichmentKeywords keywords; + private NluEnrichmentEntities entities; + private NluEnrichmentSentiment sentiment; + private NluEnrichmentEmotion emotion; + private NluEnrichmentCategories categories; + @SerializedName("semantic_roles") + private NluEnrichmentSemanticRoles semanticRoles; + private NluEnrichmentRelations relations; + + /** + * Gets the keywords. + * + * An object specifying the Keyword enrichment and related parameters. + * + * @return the keywords + */ + public NluEnrichmentKeywords getKeywords() { + return keywords; + } + + /** + * Gets the entities. + * + * An object speficying the Entities enrichment and related parameters. + * + * @return the entities + */ + public NluEnrichmentEntities getEntities() { + return entities; + } + + /** + * Gets the sentiment. + * + * An object specifying the sentiment extraction enrichment and related parameters. + * + * @return the sentiment + */ + public NluEnrichmentSentiment getSentiment() { + return sentiment; + } + + /** + * Gets the emotion. + * + * An object specifying the emotion detection enrichment and related parameters. + * + * @return the emotion + */ + public NluEnrichmentEmotion getEmotion() { + return emotion; + } + + /** + * Gets the categories. + * + * An object specifying the categories enrichment and related parameters. + * + * @return the categories + */ + public NluEnrichmentCategories getCategories() { + return categories; + } + + /** + * Gets the semanticRoles. + * + * An object specifiying the semantic roles enrichment and related parameters. + * + * @return the semanticRoles + */ + public NluEnrichmentSemanticRoles getSemanticRoles() { + return semanticRoles; + } + + /** + * Gets the relations. + * + * An object specifying the relations enrichment and related parameters. + * + * @return the relations + */ + public NluEnrichmentRelations getRelations() { + return relations; + } + + /** + * Sets the keywords. + * + * @param keywords the new keywords + */ + public void setKeywords(final NluEnrichmentKeywords keywords) { + this.keywords = keywords; + } + + /** + * Sets the entities. + * + * @param entities the new entities + */ + public void setEntities(final NluEnrichmentEntities entities) { + this.entities = entities; + } + + /** + * Sets the sentiment. + * + * @param sentiment the new sentiment + */ + public void setSentiment(final NluEnrichmentSentiment sentiment) { + this.sentiment = sentiment; + } + + /** + * Sets the emotion. + * + * @param emotion the new emotion + */ + public void setEmotion(final NluEnrichmentEmotion emotion) { + this.emotion = emotion; + } + + /** + * Sets the categories. + * + * @param categories the new categories + */ + public void setCategories(final NluEnrichmentCategories categories) { + this.categories = categories; + } + + /** + * Sets the semanticRoles. + * + * @param semanticRoles the new semanticRoles + */ + public void setSemanticRoles(final NluEnrichmentSemanticRoles semanticRoles) { + this.semanticRoles = semanticRoles; + } + + /** + * Sets the relations. + * + * @param relations the new relations + */ + public void setRelations(final NluEnrichmentRelations relations) { + this.relations = relations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java new file mode 100644 index 00000000000..764d07b90eb --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.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.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object specifying the Keyword enrichment and related parameters. + */ +public class NluEnrichmentKeywords extends GenericModel { + + private Boolean sentiment; + private Boolean emotion; + private Long limit; + + /** + * Gets the sentiment. + * + * When `true`, sentiment analysis of keywords will be performed on the specified field. + * + * @return the sentiment + */ + public Boolean isSentiment() { + return sentiment; + } + + /** + * Gets the emotion. + * + * When `true`, emotion detection of keywords will be performed on the specified field. + * + * @return the emotion + */ + public Boolean isEmotion() { + return emotion; + } + + /** + * Gets the limit. + * + * The maximum number of keywords to extract for each instance of the specified field. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Sets the sentiment. + * + * @param sentiment the new sentiment + */ + public void setSentiment(final Boolean sentiment) { + this.sentiment = sentiment; + } + + /** + * Sets the emotion. + * + * @param emotion the new emotion + */ + public void setEmotion(final Boolean emotion) { + this.emotion = emotion; + } + + /** + * Sets the limit. + * + * @param limit the new limit + */ + public void setLimit(final long limit) { + this.limit = limit; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java new file mode 100644 index 00000000000..3dc26616289 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java @@ -0,0 +1,44 @@ +/* + * 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.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object specifying the relations enrichment and related parameters. + */ +public class NluEnrichmentRelations extends GenericModel { + + private String model; + + /** + * Gets the model. + * + * The enrichement model to use with relationship extraction. May be a custom model provided by Watson Knowledge + * Studio, the public model for use with Knowledge Graph `en-news`, the default is`en-news`. + * + * @return the model + */ + public String getModel() { + return model; + } + + /** + * Sets the model. + * + * @param model the new model + */ + public void setModel(final String model) { + this.model = model; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java new file mode 100644 index 00000000000..821ee8cf428 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.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.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object specifiying the semantic roles enrichment and related parameters. + */ +public class NluEnrichmentSemanticRoles extends GenericModel { + + private Boolean entities; + private Boolean keywords; + private Long limit; + + /** + * Gets the entities. + * + * When `true` entities are extracted from the identified sentence parts. + * + * @return the entities + */ + public Boolean isEntities() { + return entities; + } + + /** + * Gets the keywords. + * + * When `true`, keywords are extracted from the identified sentence parts. + * + * @return the keywords + */ + public Boolean isKeywords() { + return keywords; + } + + /** + * Gets the limit. + * + * The maximum number of semantic roles enrichments to extact from each instance of the specified field. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Sets the entities. + * + * @param entities the new entities + */ + public void setEntities(final Boolean entities) { + this.entities = entities; + } + + /** + * Sets the keywords. + * + * @param keywords the new keywords + */ + public void setKeywords(final Boolean keywords) { + this.keywords = keywords; + } + + /** + * Sets the limit. + * + * @param limit the new limit + */ + public void setLimit(final long limit) { + this.limit = limit; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java new file mode 100644 index 00000000000..49afaf44f40 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java @@ -0,0 +1,66 @@ +/* + * 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.discovery.v1.model; + +import java.util.List; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object specifying the sentiment extraction enrichment and related parameters. + */ +public class NluEnrichmentSentiment extends GenericModel { + + private Boolean document; + private List targets; + + /** + * Gets the document. + * + * When `true`, sentiment analysis is performed on the entire field. + * + * @return the document + */ + public Boolean isDocument() { + return document; + } + + /** + * Gets the targets. + * + * A comma-separated list of target strings that will have any associated sentiment analyzed. + * + * @return the targets + */ + public List getTargets() { + return targets; + } + + /** + * Sets the document. + * + * @param document the new document + */ + public void setDocument(final Boolean document) { + this.document = document; + } + + /** + * Sets the targets. + * + * @param targets the new targets + */ + public void setTargets(final List targets) { + this.targets = targets; + } +} From 9b1f56b8e5cdd083eb6ed1e2f0c4a68b90011cb8 Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Tue, 12 Dec 2017 12:29:44 -0500 Subject: [PATCH 3/9] Update tests to use new models --- .../discovery/v1/DiscoveryServiceIT.java | 74 ++++++++++++++----- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java index 94f7d06953d..a330dcc64c1 100644 --- a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java +++ b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java @@ -56,6 +56,14 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentCategories; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEmotion; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEntities; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentFeatures; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentKeywords; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentRelations; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentSemanticRoles; +import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentSentiment; import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation; import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation.Operation; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryAggregation; @@ -496,15 +504,30 @@ public void createConfigurationIsSuccessful() { enrichment.setDescription("Erich foo to bar with baz"); enrichment.setIgnoreDownstreamErrors(true); enrichment.setOverwrite(false); - EnrichmentOptions enrichmentOptions = new EnrichmentOptions(); - enrichmentOptions.setSentiment(true); - enrichmentOptions.setExtract(Arrays.asList("qux")); - enrichmentOptions.setHierarchicalTypedRelations(false); - enrichmentOptions.setLanguage("en"); - enrichmentOptions.setModel("WhatComesAfterQux"); - enrichmentOptions.setQuotations(true); - enrichmentOptions.setShowSourceText(true); - enrichment.setOptions(enrichmentOptions); + + NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment(); + sentiment.setDocument(true); + NluEnrichmentEmotion emotion = new NluEnrichmentEmotion(); + emotion.setDocument(true); + NluEnrichmentEntities entities = new NluEnrichmentEntities(); + entities.setEmotion(true); + entities.setSentiment(true); + entities.setModel("WhatComesAfterQux"); + NluEnrichmentKeywords keywords = new NluEnrichmentKeywords(); + keywords.setEmotion(true); + keywords.setSentiment(true); + NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles(); + semanticRoles.setEntities(true); + NluEnrichmentFeatures features = new NluEnrichmentFeatures(); + features.setSentiment(sentiment); + features.setEmotion(emotion); + features.setEntities(entities); + features.setKeywords(keywords); + features.setSemanticRoles(semanticRoles); + EnrichmentOptions options = new EnrichmentOptions(); + options.setFeatures(features); + + enrichment.setOptions(options); List enrichments = Arrays.asList(enrichment); CreateConfigurationOptions createOptions = new CreateConfigurationOptions.Builder() @@ -606,15 +629,30 @@ public void updateConfigurationIsSuccessful() { enrichment.setDescription("Erich foo to bar with baz"); enrichment.setIgnoreDownstreamErrors(true); enrichment.setOverwrite(false); - EnrichmentOptions enrichmentOptions = new EnrichmentOptions(); - enrichmentOptions.setSentiment(true); - enrichmentOptions.setExtract(Arrays.asList("qux")); - enrichmentOptions.setHierarchicalTypedRelations(false); - enrichmentOptions.setLanguage("en"); - enrichmentOptions.setModel("WhatComesAfterQux"); - enrichmentOptions.setQuotations(true); - enrichmentOptions.setShowSourceText(true); - enrichment.setOptions(enrichmentOptions); + + NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment(); + sentiment.setDocument(true); + NluEnrichmentEmotion emotion = new NluEnrichmentEmotion(); + emotion.setDocument(true); + NluEnrichmentEntities entities = new NluEnrichmentEntities(); + entities.setEmotion(true); + entities.setSentiment(true); + entities.setModel("WhatComesAfterQux"); + NluEnrichmentKeywords keywords = new NluEnrichmentKeywords(); + keywords.setEmotion(true); + keywords.setSentiment(true); + NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles(); + semanticRoles.setEntities(true); + NluEnrichmentFeatures features = new NluEnrichmentFeatures(); + features.setSentiment(sentiment); + features.setEmotion(emotion); + features.setEntities(entities); + features.setKeywords(keywords); + features.setSemanticRoles(semanticRoles); + EnrichmentOptions options = new EnrichmentOptions(); + options.setFeatures(features); + + enrichment.setOptions(options); List updatedEnrichments = Arrays.asList(enrichment); UpdateConfigurationOptions.Builder updateBuilder = From 1a661ce217991896800ce851ec7cbe05826b7807 Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Tue, 12 Dec 2017 16:42:41 -0500 Subject: [PATCH 4/9] Add builders to new models and update tests --- .../discovery/v1/model/EnrichmentOptions.java | 61 ++++- .../v1/model/NluEnrichmentEmotion.java | 104 +++++++-- .../v1/model/NluEnrichmentEntities.java | 211 ++++++++++++------ .../v1/model/NluEnrichmentFeatures.java | 211 ++++++++++++------ .../v1/model/NluEnrichmentKeywords.java | 111 ++++++--- .../v1/model/NluEnrichmentRelations.java | 61 ++++- .../v1/model/NluEnrichmentSemanticRoles.java | 111 ++++++--- .../v1/model/NluEnrichmentSentiment.java | 104 +++++++-- .../discovery/v1/DiscoveryServiceIT.java | 100 +++++---- 9 files changed, 770 insertions(+), 304 deletions(-) diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java index 530d4ae5f8b..4c8e8495abe 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java @@ -22,22 +22,63 @@ public class EnrichmentOptions extends GenericModel { private NluEnrichmentFeatures features; /** - * Gets the features. - * - * An object representing the enrichment features that will be applied to the specified field. + * Builder. + */ + public static class Builder { + private NluEnrichmentFeatures features; + + private Builder(EnrichmentOptions enrichmentOptions) { + features = enrichmentOptions.features; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a EnrichmentOptions. + * + * @return the enrichmentOptions + */ + public EnrichmentOptions build() { + return new EnrichmentOptions(this); + } + + /** + * Set the features. + * + * @param features the features + * @return the EnrichmentOptions builder + */ + public Builder features(NluEnrichmentFeatures features) { + this.features = features; + return this; + } + } + + private EnrichmentOptions(Builder builder) { + features = builder.features; + } + + /** + * New builder. * - * @return the features + * @return a EnrichmentOptions builder */ - public NluEnrichmentFeatures getFeatures() { - return features; + public Builder newBuilder() { + return new Builder(this); } /** - * Sets the features. + * Gets the features. + * + * An object representing the enrichment features that will be applied to the specified field. * - * @param features the new features + * @return the features */ - public void setFeatures(final NluEnrichmentFeatures features) { - this.features = features; + public NluEnrichmentFeatures features() { + return features; } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java index c0cfd179c99..cb108a8e037 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java @@ -12,9 +12,11 @@ */ package com.ibm.watson.developer_cloud.discovery.v1.model; +import java.util.ArrayList; import java.util.List; import com.ibm.watson.developer_cloud.service.model.GenericModel; +import com.ibm.watson.developer_cloud.util.Validator; /** * An object specifying the emotion detection enrichment and related parameters. @@ -24,6 +26,86 @@ public class NluEnrichmentEmotion extends GenericModel { private Boolean document; private List targets; + /** + * Builder. + */ + public static class Builder { + private Boolean document; + private List targets; + + private Builder(NluEnrichmentEmotion nluEnrichmentEmotion) { + document = nluEnrichmentEmotion.document; + targets = nluEnrichmentEmotion.targets; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentEmotion. + * + * @return the nluEnrichmentEmotion + */ + public NluEnrichmentEmotion build() { + return new NluEnrichmentEmotion(this); + } + + /** + * Adds an targets to targets. + * + * @param targets the new targets + * @return the NluEnrichmentEmotion builder + */ + public Builder addTargets(String targets) { + Validator.notNull(targets, "targets cannot be null"); + if (this.targets == null) { + this.targets = new ArrayList(); + } + this.targets.add(targets); + return this; + } + + /** + * Set the document. + * + * @param document the document + * @return the NluEnrichmentEmotion builder + */ + public Builder document(Boolean document) { + this.document = document; + return this; + } + + /** + * Set the targets. + * Existing targets will be replaced. + * + * @param targets the targets + * @return the NluEnrichmentEmotion builder + */ + public Builder targets(List targets) { + this.targets = targets; + return this; + } + } + + private NluEnrichmentEmotion(Builder builder) { + document = builder.document; + targets = builder.targets; + } + + /** + * New builder. + * + * @return a NluEnrichmentEmotion builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the document. * @@ -31,7 +113,7 @@ public class NluEnrichmentEmotion extends GenericModel { * * @return the document */ - public Boolean isDocument() { + public Boolean document() { return document; } @@ -42,25 +124,7 @@ public Boolean isDocument() { * * @return the targets */ - public List getTargets() { + public List targets() { return targets; } - - /** - * Sets the document. - * - * @param document the new document - */ - public void setDocument(final Boolean document) { - this.document = document; - } - - /** - * Sets the targets. - * - * @param targets the new targets - */ - public void setTargets(final List targets) { - this.targets = targets; - } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java index 340aaf5861c..f9e883bde43 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java @@ -30,6 +30,140 @@ public class NluEnrichmentEntities extends GenericModel { private Boolean sentenceLocation; private String model; + /** + * Builder. + */ + public static class Builder { + private Boolean sentiment; + private Boolean emotion; + private Long limit; + private Boolean mentions; + private Boolean mentionTypes; + private Boolean sentenceLocation; + private String model; + + private Builder(NluEnrichmentEntities nluEnrichmentEntities) { + sentiment = nluEnrichmentEntities.sentiment; + emotion = nluEnrichmentEntities.emotion; + limit = nluEnrichmentEntities.limit; + mentions = nluEnrichmentEntities.mentions; + mentionTypes = nluEnrichmentEntities.mentionTypes; + sentenceLocation = nluEnrichmentEntities.sentenceLocation; + model = nluEnrichmentEntities.model; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentEntities. + * + * @return the nluEnrichmentEntities + */ + public NluEnrichmentEntities build() { + return new NluEnrichmentEntities(this); + } + + /** + * Set the sentiment. + * + * @param sentiment the sentiment + * @return the NluEnrichmentEntities builder + */ + public Builder sentiment(Boolean sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * Set the emotion. + * + * @param emotion the emotion + * @return the NluEnrichmentEntities builder + */ + public Builder emotion(Boolean emotion) { + this.emotion = emotion; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the NluEnrichmentEntities builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the mentions. + * + * @param mentions the mentions + * @return the NluEnrichmentEntities builder + */ + public Builder mentions(Boolean mentions) { + this.mentions = mentions; + return this; + } + + /** + * Set the mentionTypes. + * + * @param mentionTypes the mentionTypes + * @return the NluEnrichmentEntities builder + */ + public Builder mentionTypes(Boolean mentionTypes) { + this.mentionTypes = mentionTypes; + return this; + } + + /** + * Set the sentenceLocation. + * + * @param sentenceLocation the sentenceLocation + * @return the NluEnrichmentEntities builder + */ + public Builder sentenceLocation(Boolean sentenceLocation) { + this.sentenceLocation = sentenceLocation; + return this; + } + + /** + * Set the model. + * + * @param model the model + * @return the NluEnrichmentEntities builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + private NluEnrichmentEntities(Builder builder) { + sentiment = builder.sentiment; + emotion = builder.emotion; + limit = builder.limit; + mentions = builder.mentions; + mentionTypes = builder.mentionTypes; + sentenceLocation = builder.sentenceLocation; + model = builder.model; + } + + /** + * New builder. + * + * @return a NluEnrichmentEntities builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the sentiment. * @@ -37,7 +171,7 @@ public class NluEnrichmentEntities extends GenericModel { * * @return the sentiment */ - public Boolean isSentiment() { + public Boolean sentiment() { return sentiment; } @@ -48,7 +182,7 @@ public Boolean isSentiment() { * * @return the emotion */ - public Boolean isEmotion() { + public Boolean emotion() { return emotion; } @@ -59,7 +193,7 @@ public Boolean isEmotion() { * * @return the limit */ - public Long getLimit() { + public Long limit() { return limit; } @@ -70,7 +204,7 @@ public Long getLimit() { * * @return the mentions */ - public Boolean isMentions() { + public Boolean mentions() { return mentions; } @@ -81,7 +215,7 @@ public Boolean isMentions() { * * @return the mentionTypes */ - public Boolean isMentionTypes() { + public Boolean mentionTypes() { return mentionTypes; } @@ -93,7 +227,7 @@ public Boolean isMentionTypes() { * * @return the sentenceLocation */ - public Boolean isSentenceLocation() { + public Boolean sentenceLocation() { return sentenceLocation; } @@ -105,70 +239,7 @@ public Boolean isSentenceLocation() { * * @return the model */ - public String getModel() { + public String model() { return model; } - - /** - * Sets the sentiment. - * - * @param sentiment the new sentiment - */ - public void setSentiment(final Boolean sentiment) { - this.sentiment = sentiment; - } - - /** - * Sets the emotion. - * - * @param emotion the new emotion - */ - public void setEmotion(final Boolean emotion) { - this.emotion = emotion; - } - - /** - * Sets the limit. - * - * @param limit the new limit - */ - public void setLimit(final long limit) { - this.limit = limit; - } - - /** - * Sets the mentions. - * - * @param mentions the new mentions - */ - public void setMentions(final Boolean mentions) { - this.mentions = mentions; - } - - /** - * Sets the mentionTypes. - * - * @param mentionTypes the new mentionTypes - */ - public void setMentionTypes(final Boolean mentionTypes) { - this.mentionTypes = mentionTypes; - } - - /** - * Sets the sentenceLocation. - * - * @param sentenceLocation the new sentenceLocation - */ - public void setSentenceLocation(final Boolean sentenceLocation) { - this.sentenceLocation = sentenceLocation; - } - - /** - * Sets the model. - * - * @param model the new model - */ - public void setModel(final String model) { - this.model = model; - } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java index 4baa3ce429c..3bbb78ddf90 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java @@ -29,6 +29,140 @@ public class NluEnrichmentFeatures extends GenericModel { private NluEnrichmentSemanticRoles semanticRoles; private NluEnrichmentRelations relations; + /** + * Builder. + */ + public static class Builder { + private NluEnrichmentKeywords keywords; + private NluEnrichmentEntities entities; + private NluEnrichmentSentiment sentiment; + private NluEnrichmentEmotion emotion; + private NluEnrichmentCategories categories; + private NluEnrichmentSemanticRoles semanticRoles; + private NluEnrichmentRelations relations; + + private Builder(NluEnrichmentFeatures nluEnrichmentFeatures) { + keywords = nluEnrichmentFeatures.keywords; + entities = nluEnrichmentFeatures.entities; + sentiment = nluEnrichmentFeatures.sentiment; + emotion = nluEnrichmentFeatures.emotion; + categories = nluEnrichmentFeatures.categories; + semanticRoles = nluEnrichmentFeatures.semanticRoles; + relations = nluEnrichmentFeatures.relations; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentFeatures. + * + * @return the nluEnrichmentFeatures + */ + public NluEnrichmentFeatures build() { + return new NluEnrichmentFeatures(this); + } + + /** + * Set the keywords. + * + * @param keywords the keywords + * @return the NluEnrichmentFeatures builder + */ + public Builder keywords(NluEnrichmentKeywords keywords) { + this.keywords = keywords; + return this; + } + + /** + * Set the entities. + * + * @param entities the entities + * @return the NluEnrichmentFeatures builder + */ + public Builder entities(NluEnrichmentEntities entities) { + this.entities = entities; + return this; + } + + /** + * Set the sentiment. + * + * @param sentiment the sentiment + * @return the NluEnrichmentFeatures builder + */ + public Builder sentiment(NluEnrichmentSentiment sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * Set the emotion. + * + * @param emotion the emotion + * @return the NluEnrichmentFeatures builder + */ + public Builder emotion(NluEnrichmentEmotion emotion) { + this.emotion = emotion; + return this; + } + + /** + * Set the categories. + * + * @param categories the categories + * @return the NluEnrichmentFeatures builder + */ + public Builder categories(NluEnrichmentCategories categories) { + this.categories = categories; + return this; + } + + /** + * Set the semanticRoles. + * + * @param semanticRoles the semanticRoles + * @return the NluEnrichmentFeatures builder + */ + public Builder semanticRoles(NluEnrichmentSemanticRoles semanticRoles) { + this.semanticRoles = semanticRoles; + return this; + } + + /** + * Set the relations. + * + * @param relations the relations + * @return the NluEnrichmentFeatures builder + */ + public Builder relations(NluEnrichmentRelations relations) { + this.relations = relations; + return this; + } + } + + private NluEnrichmentFeatures(Builder builder) { + keywords = builder.keywords; + entities = builder.entities; + sentiment = builder.sentiment; + emotion = builder.emotion; + categories = builder.categories; + semanticRoles = builder.semanticRoles; + relations = builder.relations; + } + + /** + * New builder. + * + * @return a NluEnrichmentFeatures builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the keywords. * @@ -36,7 +170,7 @@ public class NluEnrichmentFeatures extends GenericModel { * * @return the keywords */ - public NluEnrichmentKeywords getKeywords() { + public NluEnrichmentKeywords keywords() { return keywords; } @@ -47,7 +181,7 @@ public NluEnrichmentKeywords getKeywords() { * * @return the entities */ - public NluEnrichmentEntities getEntities() { + public NluEnrichmentEntities entities() { return entities; } @@ -58,7 +192,7 @@ public NluEnrichmentEntities getEntities() { * * @return the sentiment */ - public NluEnrichmentSentiment getSentiment() { + public NluEnrichmentSentiment sentiment() { return sentiment; } @@ -69,7 +203,7 @@ public NluEnrichmentSentiment getSentiment() { * * @return the emotion */ - public NluEnrichmentEmotion getEmotion() { + public NluEnrichmentEmotion emotion() { return emotion; } @@ -80,7 +214,7 @@ public NluEnrichmentEmotion getEmotion() { * * @return the categories */ - public NluEnrichmentCategories getCategories() { + public NluEnrichmentCategories categories() { return categories; } @@ -91,7 +225,7 @@ public NluEnrichmentCategories getCategories() { * * @return the semanticRoles */ - public NluEnrichmentSemanticRoles getSemanticRoles() { + public NluEnrichmentSemanticRoles semanticRoles() { return semanticRoles; } @@ -102,70 +236,7 @@ public NluEnrichmentSemanticRoles getSemanticRoles() { * * @return the relations */ - public NluEnrichmentRelations getRelations() { + public NluEnrichmentRelations relations() { return relations; } - - /** - * Sets the keywords. - * - * @param keywords the new keywords - */ - public void setKeywords(final NluEnrichmentKeywords keywords) { - this.keywords = keywords; - } - - /** - * Sets the entities. - * - * @param entities the new entities - */ - public void setEntities(final NluEnrichmentEntities entities) { - this.entities = entities; - } - - /** - * Sets the sentiment. - * - * @param sentiment the new sentiment - */ - public void setSentiment(final NluEnrichmentSentiment sentiment) { - this.sentiment = sentiment; - } - - /** - * Sets the emotion. - * - * @param emotion the new emotion - */ - public void setEmotion(final NluEnrichmentEmotion emotion) { - this.emotion = emotion; - } - - /** - * Sets the categories. - * - * @param categories the new categories - */ - public void setCategories(final NluEnrichmentCategories categories) { - this.categories = categories; - } - - /** - * Sets the semanticRoles. - * - * @param semanticRoles the new semanticRoles - */ - public void setSemanticRoles(final NluEnrichmentSemanticRoles semanticRoles) { - this.semanticRoles = semanticRoles; - } - - /** - * Sets the relations. - * - * @param relations the new relations - */ - public void setRelations(final NluEnrichmentRelations relations) { - this.relations = relations; - } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java index 764d07b90eb..ddbd8878062 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java @@ -23,6 +23,84 @@ public class NluEnrichmentKeywords extends GenericModel { private Boolean emotion; private Long limit; + /** + * Builder. + */ + public static class Builder { + private Boolean sentiment; + private Boolean emotion; + private Long limit; + + private Builder(NluEnrichmentKeywords nluEnrichmentKeywords) { + sentiment = nluEnrichmentKeywords.sentiment; + emotion = nluEnrichmentKeywords.emotion; + limit = nluEnrichmentKeywords.limit; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentKeywords. + * + * @return the nluEnrichmentKeywords + */ + public NluEnrichmentKeywords build() { + return new NluEnrichmentKeywords(this); + } + + /** + * Set the sentiment. + * + * @param sentiment the sentiment + * @return the NluEnrichmentKeywords builder + */ + public Builder sentiment(Boolean sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * Set the emotion. + * + * @param emotion the emotion + * @return the NluEnrichmentKeywords builder + */ + public Builder emotion(Boolean emotion) { + this.emotion = emotion; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the NluEnrichmentKeywords builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + } + + private NluEnrichmentKeywords(Builder builder) { + sentiment = builder.sentiment; + emotion = builder.emotion; + limit = builder.limit; + } + + /** + * New builder. + * + * @return a NluEnrichmentKeywords builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the sentiment. * @@ -30,7 +108,7 @@ public class NluEnrichmentKeywords extends GenericModel { * * @return the sentiment */ - public Boolean isSentiment() { + public Boolean sentiment() { return sentiment; } @@ -41,7 +119,7 @@ public Boolean isSentiment() { * * @return the emotion */ - public Boolean isEmotion() { + public Boolean emotion() { return emotion; } @@ -52,34 +130,7 @@ public Boolean isEmotion() { * * @return the limit */ - public Long getLimit() { + public Long limit() { return limit; } - - /** - * Sets the sentiment. - * - * @param sentiment the new sentiment - */ - public void setSentiment(final Boolean sentiment) { - this.sentiment = sentiment; - } - - /** - * Sets the emotion. - * - * @param emotion the new emotion - */ - public void setEmotion(final Boolean emotion) { - this.emotion = emotion; - } - - /** - * Sets the limit. - * - * @param limit the new limit - */ - public void setLimit(final long limit) { - this.limit = limit; - } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java index 3dc26616289..a07116b68a8 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java @@ -21,6 +21,56 @@ public class NluEnrichmentRelations extends GenericModel { private String model; + /** + * Builder. + */ + public static class Builder { + private String model; + + private Builder(NluEnrichmentRelations nluEnrichmentRelations) { + model = nluEnrichmentRelations.model; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentRelations. + * + * @return the nluEnrichmentRelations + */ + public NluEnrichmentRelations build() { + return new NluEnrichmentRelations(this); + } + + /** + * Set the model. + * + * @param model the model + * @return the NluEnrichmentRelations builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + private NluEnrichmentRelations(Builder builder) { + model = builder.model; + } + + /** + * New builder. + * + * @return a NluEnrichmentRelations builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the model. * @@ -29,16 +79,7 @@ public class NluEnrichmentRelations extends GenericModel { * * @return the model */ - public String getModel() { + public String model() { return model; } - - /** - * Sets the model. - * - * @param model the new model - */ - public void setModel(final String model) { - this.model = model; - } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java index 821ee8cf428..c9a1dd5e803 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java @@ -23,6 +23,84 @@ public class NluEnrichmentSemanticRoles extends GenericModel { private Boolean keywords; private Long limit; + /** + * Builder. + */ + public static class Builder { + private Boolean entities; + private Boolean keywords; + private Long limit; + + private Builder(NluEnrichmentSemanticRoles nluEnrichmentSemanticRoles) { + entities = nluEnrichmentSemanticRoles.entities; + keywords = nluEnrichmentSemanticRoles.keywords; + limit = nluEnrichmentSemanticRoles.limit; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentSemanticRoles. + * + * @return the nluEnrichmentSemanticRoles + */ + public NluEnrichmentSemanticRoles build() { + return new NluEnrichmentSemanticRoles(this); + } + + /** + * Set the entities. + * + * @param entities the entities + * @return the NluEnrichmentSemanticRoles builder + */ + public Builder entities(Boolean entities) { + this.entities = entities; + return this; + } + + /** + * Set the keywords. + * + * @param keywords the keywords + * @return the NluEnrichmentSemanticRoles builder + */ + public Builder keywords(Boolean keywords) { + this.keywords = keywords; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the NluEnrichmentSemanticRoles builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + } + + private NluEnrichmentSemanticRoles(Builder builder) { + entities = builder.entities; + keywords = builder.keywords; + limit = builder.limit; + } + + /** + * New builder. + * + * @return a NluEnrichmentSemanticRoles builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the entities. * @@ -30,7 +108,7 @@ public class NluEnrichmentSemanticRoles extends GenericModel { * * @return the entities */ - public Boolean isEntities() { + public Boolean entities() { return entities; } @@ -41,7 +119,7 @@ public Boolean isEntities() { * * @return the keywords */ - public Boolean isKeywords() { + public Boolean keywords() { return keywords; } @@ -52,34 +130,7 @@ public Boolean isKeywords() { * * @return the limit */ - public Long getLimit() { + public Long limit() { return limit; } - - /** - * Sets the entities. - * - * @param entities the new entities - */ - public void setEntities(final Boolean entities) { - this.entities = entities; - } - - /** - * Sets the keywords. - * - * @param keywords the new keywords - */ - public void setKeywords(final Boolean keywords) { - this.keywords = keywords; - } - - /** - * Sets the limit. - * - * @param limit the new limit - */ - public void setLimit(final long limit) { - this.limit = limit; - } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java index 49afaf44f40..27d371c5f2a 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java @@ -12,9 +12,11 @@ */ package com.ibm.watson.developer_cloud.discovery.v1.model; +import java.util.ArrayList; import java.util.List; import com.ibm.watson.developer_cloud.service.model.GenericModel; +import com.ibm.watson.developer_cloud.util.Validator; /** * An object specifying the sentiment extraction enrichment and related parameters. @@ -24,6 +26,86 @@ public class NluEnrichmentSentiment extends GenericModel { private Boolean document; private List targets; + /** + * Builder. + */ + public static class Builder { + private Boolean document; + private List targets; + + private Builder(NluEnrichmentSentiment nluEnrichmentSentiment) { + document = nluEnrichmentSentiment.document; + targets = nluEnrichmentSentiment.targets; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a NluEnrichmentSentiment. + * + * @return the nluEnrichmentSentiment + */ + public NluEnrichmentSentiment build() { + return new NluEnrichmentSentiment(this); + } + + /** + * Adds an targets to targets. + * + * @param targets the new targets + * @return the NluEnrichmentSentiment builder + */ + public Builder addTargets(String targets) { + Validator.notNull(targets, "targets cannot be null"); + if (this.targets == null) { + this.targets = new ArrayList(); + } + this.targets.add(targets); + return this; + } + + /** + * Set the document. + * + * @param document the document + * @return the NluEnrichmentSentiment builder + */ + public Builder document(Boolean document) { + this.document = document; + return this; + } + + /** + * Set the targets. + * Existing targets will be replaced. + * + * @param targets the targets + * @return the NluEnrichmentSentiment builder + */ + public Builder targets(List targets) { + this.targets = targets; + return this; + } + } + + private NluEnrichmentSentiment(Builder builder) { + document = builder.document; + targets = builder.targets; + } + + /** + * New builder. + * + * @return a NluEnrichmentSentiment builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the document. * @@ -31,7 +113,7 @@ public class NluEnrichmentSentiment extends GenericModel { * * @return the document */ - public Boolean isDocument() { + public Boolean document() { return document; } @@ -42,25 +124,7 @@ public Boolean isDocument() { * * @return the targets */ - public List getTargets() { + public List targets() { return targets; } - - /** - * Sets the document. - * - * @param document the new document - */ - public void setDocument(final Boolean document) { - this.document = document; - } - - /** - * Sets the targets. - * - * @param targets the new targets - */ - public void setTargets(final List targets) { - this.targets = targets; - } } diff --git a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java index a330dcc64c1..2ecc7cc205e 100644 --- a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java +++ b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java @@ -56,12 +56,10 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentCategories; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEmotion; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEntities; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentFeatures; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentKeywords; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentRelations; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentSemanticRoles; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentSentiment; import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation; @@ -505,27 +503,34 @@ public void createConfigurationIsSuccessful() { enrichment.setIgnoreDownstreamErrors(true); enrichment.setOverwrite(false); - NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment(); - sentiment.setDocument(true); - NluEnrichmentEmotion emotion = new NluEnrichmentEmotion(); - emotion.setDocument(true); - NluEnrichmentEntities entities = new NluEnrichmentEntities(); - entities.setEmotion(true); - entities.setSentiment(true); - entities.setModel("WhatComesAfterQux"); - NluEnrichmentKeywords keywords = new NluEnrichmentKeywords(); - keywords.setEmotion(true); - keywords.setSentiment(true); - NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles(); - semanticRoles.setEntities(true); - NluEnrichmentFeatures features = new NluEnrichmentFeatures(); - features.setSentiment(sentiment); - features.setEmotion(emotion); - features.setEntities(entities); - features.setKeywords(keywords); - features.setSemanticRoles(semanticRoles); - EnrichmentOptions options = new EnrichmentOptions(); - options.setFeatures(features); + NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment.Builder() + .document(true) + .build(); + NluEnrichmentEmotion emotion = new NluEnrichmentEmotion.Builder() + .document(true) + .build(); + NluEnrichmentEntities entities = new NluEnrichmentEntities.Builder() + .emotion(true) + .sentiment(true) + .model("WhatComesAfterQux") + .build(); + NluEnrichmentKeywords keywords = new NluEnrichmentKeywords.Builder() + .emotion(true) + .sentiment(true) + .build(); + NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .build(); + NluEnrichmentFeatures features = new NluEnrichmentFeatures.Builder() + .sentiment(sentiment) + .emotion(emotion) + .entities(entities) + .keywords(keywords) + .semanticRoles(semanticRoles) + .build(); + EnrichmentOptions options = new EnrichmentOptions.Builder() + .features(features) + .build(); enrichment.setOptions(options); List enrichments = Arrays.asList(enrichment); @@ -630,27 +635,34 @@ public void updateConfigurationIsSuccessful() { enrichment.setIgnoreDownstreamErrors(true); enrichment.setOverwrite(false); - NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment(); - sentiment.setDocument(true); - NluEnrichmentEmotion emotion = new NluEnrichmentEmotion(); - emotion.setDocument(true); - NluEnrichmentEntities entities = new NluEnrichmentEntities(); - entities.setEmotion(true); - entities.setSentiment(true); - entities.setModel("WhatComesAfterQux"); - NluEnrichmentKeywords keywords = new NluEnrichmentKeywords(); - keywords.setEmotion(true); - keywords.setSentiment(true); - NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles(); - semanticRoles.setEntities(true); - NluEnrichmentFeatures features = new NluEnrichmentFeatures(); - features.setSentiment(sentiment); - features.setEmotion(emotion); - features.setEntities(entities); - features.setKeywords(keywords); - features.setSemanticRoles(semanticRoles); - EnrichmentOptions options = new EnrichmentOptions(); - options.setFeatures(features); + NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment.Builder() + .document(true) + .build(); + NluEnrichmentEmotion emotion = new NluEnrichmentEmotion.Builder() + .document(true) + .build(); + NluEnrichmentEntities entities = new NluEnrichmentEntities.Builder() + .emotion(true) + .sentiment(true) + .model("WhatComesAfterQux") + .build(); + NluEnrichmentKeywords keywords = new NluEnrichmentKeywords.Builder() + .emotion(true) + .sentiment(true) + .build(); + NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .build(); + NluEnrichmentFeatures features = new NluEnrichmentFeatures.Builder() + .sentiment(sentiment) + .emotion(emotion) + .entities(entities) + .keywords(keywords) + .semanticRoles(semanticRoles) + .build(); + EnrichmentOptions options = new EnrichmentOptions.Builder() + .features(features) + .build(); enrichment.setOptions(options); List updatedEnrichments = Arrays.asList(enrichment); From 78816b3cce2c82c56b6bd887b1178bd64078932e Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Thu, 14 Dec 2017 13:49:05 -0500 Subject: [PATCH 5/9] Add handwritten method for getting profile in CSV format (#833) * Add handwritten method for getting profile in CSV format * Remove csvHeaders property from ProfileOptions --- .../v3/PersonalityInsights.java | 33 +++++++++++++++++-- .../v3/model/ProfileOptions.java | 27 --------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java index 4697e787937..e25a56597e0 100644 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java +++ b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java @@ -12,6 +12,8 @@ */ package com.ibm.watson.developer_cloud.personality_insights.v3; +import com.ibm.watson.developer_cloud.http.HttpHeaders; +import com.ibm.watson.developer_cloud.http.HttpMediaType; import com.ibm.watson.developer_cloud.http.RequestBuilder; import com.ibm.watson.developer_cloud.http.ServiceCall; import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile; @@ -120,9 +122,6 @@ public ServiceCall profile(ProfileOptions profileOptions) { if (profileOptions.rawScores() != null) { builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); } - if (profileOptions.csvHeaders() != null) { - builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders())); - } if (profileOptions.consumptionPreferences() != null) { builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); } @@ -134,4 +133,32 @@ public ServiceCall profile(ProfileOptions profileOptions) { return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Profile.class)); } + public ServiceCall getProfileAsCSV(ProfileOptions profileOptions, boolean includeHeaders) { + Validator.notNull(profileOptions, "profileOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post("/v3/profile"); + builder.query(VERSION, versionDate); + builder.header("Content-Type", profileOptions.contentType()); + if (profileOptions.contentLanguage() != null) { + builder.header("Content-Language", profileOptions.contentLanguage()); + } + if (profileOptions.acceptLanguage() != null) { + builder.header("Accept-Language", profileOptions.acceptLanguage()); + } + if (profileOptions.rawScores() != null) { + builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); + } + if (profileOptions.consumptionPreferences() != null) { + builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); + } + if (profileOptions.contentType().equalsIgnoreCase(ProfileOptions.ContentType.APPLICATION_JSON)) { + builder.bodyJson(GsonSingleton.getGson().toJsonTree(profileOptions.content()).getAsJsonObject()); + } else { + builder.bodyContent(profileOptions.body(), profileOptions.contentType()); + } + + builder.header(HttpHeaders.ACCEPT, HttpMediaType.TEXT_CSV); + builder.query("headers", includeHeaders); + + return createServiceCall(builder.build(), ResponseConverterUtils.getString()); + } } diff --git a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ProfileOptions.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ProfileOptions.java index f0c13249fd1..c79d1815960 100644 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ProfileOptions.java +++ b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ProfileOptions.java @@ -92,7 +92,6 @@ public interface AcceptLanguage { private String contentLanguage; private String acceptLanguage; private Boolean rawScores; - private Boolean csvHeaders; private Boolean consumptionPreferences; /** @@ -105,7 +104,6 @@ public static class Builder { private String contentLanguage; private String acceptLanguage; private Boolean rawScores; - private Boolean csvHeaders; private Boolean consumptionPreferences; private Builder(ProfileOptions profileOptions) { @@ -115,7 +113,6 @@ private Builder(ProfileOptions profileOptions) { contentLanguage = profileOptions.contentLanguage; acceptLanguage = profileOptions.acceptLanguage; rawScores = profileOptions.rawScores; - csvHeaders = profileOptions.csvHeaders; consumptionPreferences = profileOptions.consumptionPreferences; } @@ -167,17 +164,6 @@ public Builder rawScores(Boolean rawScores) { return this; } - /** - * Set the csvHeaders. - * - * @param csvHeaders the csvHeaders - * @return the ProfileOptions builder - */ - public Builder csvHeaders(Boolean csvHeaders) { - this.csvHeaders = csvHeaders; - return this; - } - /** * Set the consumptionPreferences. * @@ -234,7 +220,6 @@ private ProfileOptions(Builder builder) { contentLanguage = builder.contentLanguage; acceptLanguage = builder.acceptLanguage; rawScores = builder.rawScores; - csvHeaders = builder.csvHeaders; consumptionPreferences = builder.consumptionPreferences; } @@ -328,18 +313,6 @@ public Boolean rawScores() { return rawScores; } - /** - * Gets the csvHeaders. - * - * If `true`, column labels are returned with a CSV response; if `false` (the default), they are not. Applies only - * when the `Accept` header is set to `text/csv`. - * - * @return the csvHeaders - */ - public Boolean csvHeaders() { - return csvHeaders; - } - /** * Gets the consumptionPreferences. * From 57aa9b6f33c0804b310e446755a5fa6910e5c4ca Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Thu, 14 Dec 2017 15:11:21 -0500 Subject: [PATCH 6/9] Fix reference to old property in personality insights --- .../personality_insights/v3/PersonalityInsightsTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java b/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java index 9d97168fb2f..86fe85d0f6c 100644 --- a/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java +++ b/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java @@ -218,13 +218,11 @@ public void testProfileBuilders() { .html(text) .contentLanguage(ProfileOptions.ContentLanguage.ES) .acceptLanguage(ProfileOptions.AcceptLanguage.EN) - .csvHeaders(true) .build(); final ProfileOptions newOptions = options.newBuilder().build(); assertEquals(newOptions.body(), text); assertEquals(newOptions.contentLanguage(), ProfileOptions.ContentLanguage.ES); assertEquals(newOptions.acceptLanguage(), ProfileOptions.AcceptLanguage.EN); - assertEquals(newOptions.csvHeaders(), true); } /** From ca526cfc2dde139395a76738491898fed47f8d63 Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Thu, 14 Dec 2017 17:09:57 -0500 Subject: [PATCH 7/9] Automatic jar upload. Fixes #831 (#832) * Add JDNI test library as gradle dependency * Add GitHub releases deployment for Travis * Address review comments * Fix variable syntax --- .bumpversion.cfg | 3 --- .travis.yml | 8 ++++++++ core/build.gradle | 1 + .../watson/developer_cloud/util/CredentialUtilsTest.java | 2 -- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 346de06b7e0..80940870e3a 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,5 @@ [bumpversion] current_version = 4.1.0 -commit = True -tag = True [bumpversion:file:README.md] @@ -34,4 +32,3 @@ tag = True [bumpversion:file:visual-recognition/README.md] search = {current_version} replace = {new_version} - diff --git a/.travis.yml b/.travis.yml index 404a58eac3a..7fbae78676e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,5 +56,13 @@ deploy: repo: watson-developer-cloud/java-sdk jdk: oraclejdk7 + - provider: releases + api_key: ${GITHUB_TOKEN_RELEASES} + file: java-sdk/build/libs/jar-with-dependencies-${TRAVIS_BRANCH}.jar + skip_cleanup: true + on: + repo: watson-developer-cloud/java-sdk + jdk: oraclejdk7 + tags: true notifications: email: true diff --git a/core/build.gradle b/core/build.gradle index 135b8d0780d..35f3d5f52e2 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -75,6 +75,7 @@ dependencies { compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5' compile group: 'org.glassfish.jersey.bundles.repackaged', name: 'jersey-jsr166e', version: '2.25.1' + testCompile group: 'simple-jndi', name: 'simple-jndi', version: '0.11.4.1' signature 'org.codehaus.mojo.signature:java17:1.0@signature' diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java index 20cd17ec7c0..445d344d1b4 100644 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java +++ b/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java @@ -15,7 +15,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; import java.io.InputStream; import java.util.Hashtable; @@ -131,7 +130,6 @@ public void testGetUserCredentialsWithPlan() { */ @Test public void testGetAPIUrlFromJDNI() { - assumeTrue(!System.getenv().containsKey("TRAVIS")); assertEquals(CredentialUtils.getAPIUrlTest(SERVICE_NAME), PERSONALITY_INSIGHTS_URL); } } From 76a52190a819e5065b2420fe1ebf757b6a3c6fce Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Fri, 15 Dec 2017 15:16:58 -0500 Subject: [PATCH 8/9] Address review comments regarding array setters in new models --- .../discovery/v1/model/NluEnrichmentEmotion.java | 6 +++--- .../discovery/v1/model/NluEnrichmentSentiment.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java index cb108a8e037..d89eafc2038 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java @@ -59,12 +59,12 @@ public NluEnrichmentEmotion build() { * @param targets the new targets * @return the NluEnrichmentEmotion builder */ - public Builder addTargets(String targets) { - Validator.notNull(targets, "targets cannot be null"); + public Builder addTarget(String target) { + Validator.notNull(target, "target cannot be null"); if (this.targets == null) { this.targets = new ArrayList(); } - this.targets.add(targets); + this.targets.add(target); return this; } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java index 27d371c5f2a..6e46cf148d2 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java @@ -59,12 +59,12 @@ public NluEnrichmentSentiment build() { * @param targets the new targets * @return the NluEnrichmentSentiment builder */ - public Builder addTargets(String targets) { - Validator.notNull(targets, "targets cannot be null"); + public Builder addTarget(String target) { + Validator.notNull(target, "target cannot be null"); if (this.targets == null) { this.targets = new ArrayList(); } - this.targets.add(targets); + this.targets.add(target); return this; } From dbc923f311a4654d9c0eed542db8a496c3f5ebd9 Mon Sep 17 00:00:00 2001 From: Logan Patino Date: Fri, 15 Dec 2017 15:38:44 -0500 Subject: [PATCH 9/9] :green_heart: Fix build error with java docs --- .../discovery/v1/model/NluEnrichmentEmotion.java | 4 ++-- .../discovery/v1/model/NluEnrichmentSentiment.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java index d89eafc2038..8c71ee8aa88 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java @@ -54,9 +54,9 @@ public NluEnrichmentEmotion build() { } /** - * Adds an targets to targets. + * Adds a target to targets. * - * @param targets the new targets + * @param target the new target * @return the NluEnrichmentEmotion builder */ public Builder addTarget(String target) { diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java index 6e46cf148d2..8e27a3408fe 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java @@ -54,9 +54,9 @@ public NluEnrichmentSentiment build() { } /** - * Adds an targets to targets. + * Adds a target to targets. * - * @param targets the new targets + * @param target the new target * @return the NluEnrichmentSentiment builder */ public Builder addTarget(String target) {