Skip to content

Commit 80724e6

Browse files
Merge pull request #403 from watson-developer-cloud/pr/370
Add typed relations to alchemy language
2 parents 010edb5 + 9839d6c commit 80724e6

File tree

16 files changed

+260
-138
lines changed

16 files changed

+260
-138
lines changed

.config.properties.enc

0 Bytes
Binary file not shown.

examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage;
2121
import com.ibm.watson.developer_cloud.alchemy.v1.model.DocumentSentiment;
2222
import com.ibm.watson.developer_cloud.alchemy.v1.model.Entities;
23+
import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelations;
2324

2425
public class AlchemyLanguageExample {
2526

@@ -31,12 +32,18 @@ public static void main(String[] args) {
3132
params.put(AlchemyLanguage.TEXT,
3233
"IBM Watson won the Jeopardy television show hosted by Alex Trebek");
3334

35+
// get sentiment
3436
DocumentSentiment sentiment = service.getSentiment(params).execute();
3537
System.out.println("Sentiment: " + sentiment);
36-
38+
39+
// get entities
3740
Entities entities = service.getEntities(params).execute();
3841
System.out.println("Entities: " + entities);
3942

43+
// get typed relations
44+
TypedRelations relations = service.getTypedRelations(params).execute();
45+
System.out.println("Relations: " + relations);
46+
4047
}
4148

4249
}

src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Article.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static class EnrichedTitle extends GenericModel {
3737
private Sentiment sentiment;
3838
private List<Taxonomy> taxonomy;
3939

40-
40+
4141
/**
4242
* Gets the concepts.
4343
*
@@ -64,6 +64,7 @@ public List<Entity> getEntities() {
6464
public List<Keyword> getKeywords() {
6565
return keywords;
6666
}
67+
6768
/**
6869
* Gets the relations.
6970
*
@@ -72,7 +73,7 @@ public List<Keyword> getKeywords() {
7273
public List<SAORelation> getRelations() {
7374
return relations;
7475
}
75-
76+
7677
/**
7778
* Gets the sentiment.
7879
*
@@ -200,6 +201,7 @@ public List<Concept> getConcepts() {
200201
public EnrichedTitle getEnrichedTitle() {
201202
return enrichedTitle;
202203
}
204+
203205
/**
204206
* Gets the entities.
205207
*
@@ -208,6 +210,7 @@ public EnrichedTitle getEnrichedTitle() {
208210
public List<Entity> getEntities() {
209211
return entities;
210212
}
213+
211214
/**
212215
* Gets the feeds.
213216
*
@@ -216,6 +219,7 @@ public List<Entity> getEntities() {
216219
public List<Feed> getFeeds() {
217220
return feeds;
218221
}
222+
219223
/**
220224
* Gets the image.
221225
*
@@ -224,6 +228,7 @@ public List<Feed> getFeeds() {
224228
public String getImage() {
225229
return image;
226230
}
231+
227232
/**
228233
* Gets the image keywords.
229234
*
@@ -232,6 +237,7 @@ public String getImage() {
232237
public List<ImageKeyword> getImageKeywords() {
233238
return imageKeywords;
234239
}
240+
235241
/**
236242
* Gets the keywords.
237243
*
@@ -240,6 +246,7 @@ public List<ImageKeyword> getImageKeywords() {
240246
public List<Keyword> getKeywords() {
241247
return keywords;
242248
}
249+
243250
/**
244251
* Gets the language.
245252
*
@@ -248,6 +255,7 @@ public List<Keyword> getKeywords() {
248255
public String getLanguage() {
249256
return language;
250257
}
258+
251259
/**
252260
* Gets the publication date.
253261
*
@@ -256,6 +264,7 @@ public String getLanguage() {
256264
public PublicationDate getPublicationDate() {
257265
return publicationDate;
258266
}
267+
259268
/**
260269
* Gets the relations.
261270
*
@@ -264,6 +273,7 @@ public PublicationDate getPublicationDate() {
264273
public List<SAORelation> getRelations() {
265274
return relations;
266275
}
276+
267277
/**
268278
* Gets the sentiment.
269279
*
@@ -272,6 +282,7 @@ public List<SAORelation> getRelations() {
272282
public Sentiment getSentiment() {
273283
return sentiment;
274284
}
285+
275286
/**
276287
* Gets the taxonomy.
277288
*
@@ -280,6 +291,7 @@ public Sentiment getSentiment() {
280291
public List<Taxonomy> getTaxonomy() {
281292
return taxonomy;
282293
}
294+
283295
/**
284296
* Gets the text.
285297
*
@@ -288,6 +300,7 @@ public List<Taxonomy> getTaxonomy() {
288300
public String getText() {
289301
return text;
290302
}
303+
291304
/**
292305
* Gets the title.
293306
*
@@ -296,6 +309,7 @@ public String getText() {
296309
public String getTitle() {
297310
return title;
298311
}
312+
299313
/**
300314
* Gets the url.
301315
*
@@ -304,6 +318,7 @@ public String getTitle() {
304318
public String getUrl() {
305319
return url;
306320
}
321+
307322
/**
308323
* Sets the author.
309324
*
@@ -322,7 +337,7 @@ public void setCleanedTitle(String cleanedTitle) {
322337
this.cleanedTitle = cleanedTitle;
323338
}
324339

325-
340+
326341
/**
327342
* Sets the concepts.
328343
*
@@ -349,7 +364,7 @@ public void setEnrichedTitle(EnrichedTitle enrichedTitle) {
349364
public void setEntities(List<Entity> entities) {
350365
this.entities = entities;
351366
}
352-
367+
353368
/**
354369
* Sets the feeds.
355370
*

src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public String getText() {
6565
* @param hierarchy The hierarchy.
6666
*/
6767
public void setHierarchy(String hierarchy) {
68-
if(knowledgeGraph == null) {
68+
if (knowledgeGraph == null) {
6969
knowledgeGraph = new KnowledgeGraph();
7070
}
7171

src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Taxonomy.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package com.ibm.watson.developer_cloud.alchemy.v1.model;
1515

1616
import com.google.gson.annotations.JsonAdapter;
17-
1817
import com.ibm.watson.developer_cloud.service.model.GenericModel;
1918
import com.ibm.watson.developer_cloud.util.BooleanToStringTypeAdapter;
2019

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.ibm.watson.developer_cloud.alchemy.v1.model;
15+
16+
import java.util.List;
17+
18+
import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage;
19+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
20+
21+
/**
22+
* Argument of a typed relation. It includes the detected {@link TypedEntity}, text and part.
23+
*
24+
* @see AlchemyLanguage#getTypedRelations(java.util.Map)
25+
*/
26+
public class TypedArguments extends GenericModel {
27+
28+
private String part;
29+
private String text;
30+
private List<TypedEntity> entities;
31+
32+
/**
33+
* Gets the entities.
34+
*
35+
* @return the entities
36+
*/
37+
public List<TypedEntity> getEntities() {
38+
return entities;
39+
}
40+
41+
/**
42+
* Sets the entities.
43+
*
44+
* @param entities the new entities
45+
*/
46+
public void setTypedEntities(List<TypedEntity> entities) {
47+
this.entities = entities;
48+
}
49+
50+
/**
51+
* Gets the part.
52+
*
53+
* @return the part
54+
*/
55+
public String getPart() {
56+
return part;
57+
}
58+
59+
/**
60+
* Sets the part.
61+
*
62+
* @param part the new part
63+
*/
64+
public void setPart(String part) {
65+
this.part = part;
66+
}
67+
68+
/**
69+
* Gets the text.
70+
*
71+
* @return the text
72+
*/
73+
public String getText() {
74+
return text;
75+
}
76+
77+
/**
78+
* Sets the text.
79+
*
80+
* @param text the new text
81+
*/
82+
public void setText(String text) {
83+
this.text = text;
84+
}
85+
86+
}

src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntity.java

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@
1414

1515
package com.ibm.watson.developer_cloud.alchemy.v1.model;
1616

17-
import com.google.gson.annotations.SerializedName;
1817
import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage;
18+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
1919

2020
/**
2121
* Recognized entity from {@link AlchemyLanguage#getTypedRelations(java.util.Map)}
2222
*/
23-
public class TypedEntity {
23+
public class TypedEntity extends GenericModel {
2424

25+
private String id;
2526
private String text;
26-
private String mention;
2727
private String type;
28-
@SerializedName("argNum")
29-
private Integer argumentNumber;
30-
private String id;
3128

3229
/**
3330
* Gets the text.
@@ -47,24 +44,6 @@ public void setText(String text) {
4744
this.text = text;
4845
}
4946

50-
/**
51-
* Gets the mention.
52-
*
53-
* @return The mention
54-
*/
55-
public String getMention() {
56-
return mention;
57-
}
58-
59-
/**
60-
* Sets the mention.
61-
*
62-
* @param mention The mention
63-
*/
64-
public void setMention(String mention) {
65-
this.mention = mention;
66-
}
67-
6847
/**
6948
* Gets the type.
7049
*
@@ -83,24 +62,6 @@ public void setType(String type) {
8362
this.type = type;
8463
}
8564

86-
/**
87-
* Gets the argument number.
88-
*
89-
* @return The argument number
90-
*/
91-
public Integer getArgumentNumber() {
92-
return argumentNumber;
93-
}
94-
95-
/**
96-
* Sets the argument number.
97-
*
98-
* @param argumentNumber the new argument number
99-
*/
100-
public void setArgumentNumber(Integer argumentNumber) {
101-
this.argumentNumber = argumentNumber;
102-
}
103-
10465
/**
10566
* Gets the id.
10667
*

0 commit comments

Comments
 (0)