Skip to content

Commit b634d3a

Browse files
author
Li Xu
committed
Merge branch 'rosapi-1.8'
2 parents 77d4652 + 99513e0 commit b634d3a

File tree

8 files changed

+93
-17
lines changed

8 files changed

+93
-17
lines changed

json/src/main/java/com/basistech/rosette/apimodel/jackson/EntitiesOptionsMixin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public final class EntitiesOptionsMixin extends OptionsMixin {
2525
@JsonCreator
2626
private EntitiesOptionsMixin(
2727
@JsonProperty("calculateConfidence") Boolean calculateConfidence,
28+
@JsonProperty("calculateSalience") Boolean calculateSalience,
2829
@JsonProperty("linkEntities") Boolean linkEntities
2930
) {
3031
//

json/src/main/java/com/basistech/rosette/apimodel/jackson/EntityMentionMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public EntityMentionMixin(
3131
@JsonProperty("count") Integer count,
3232
@JsonProperty("mentionOffsets") List<MentionOffsets> mentionOffsets,
3333
@JsonProperty("entityId") String entityId,
34-
@JsonProperty("confidence") Double confidence
34+
@JsonProperty("confidence") Double confidence,
35+
@JsonProperty("salience") Double salience
3536
) {
3637
//
3738
}

json/src/main/java/com/basistech/rosette/apimodel/jackson/EntitySentimentMixin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public EntitySentimentMixin(
3636
@JsonProperty("mentionOffsets") List<MentionOffsets> mentionOffsets,
3737
@JsonProperty("entityId") String entityId,
3838
@JsonProperty("confidence") Double confidence,
39+
@JsonProperty("salience") Double salience,
3940
@JsonProperty("sentiment") Label sentiment) {
4041
//
4142
}

json/src/main/java/com/basistech/rosette/apimodel/jackson/SentimentOptionsMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
public abstract class SentimentOptionsMixin extends OptionsMixin {
2525
@JsonCreator
2626
protected SentimentOptionsMixin(
27-
@JsonProperty("calculateEntityConfidence") Boolean calculateEntityConfidence
27+
@JsonProperty("calculateEntityConfidence") Boolean calculateEntityConfidence,
28+
@JsonProperty("calculateEntitySalience") Boolean calculateEntitySalience
2829
) {
2930
//
3031
}

model/src/main/java/com/basistech/rosette/apimodel/EntitiesOptions.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
*/
2424
public final class EntitiesOptions extends Options {
2525

26-
public static final EntitiesOptions DEFAULT_OPTIONS = new EntitiesOptions(false, true);
26+
public static final EntitiesOptions DEFAULT_OPTIONS = new EntitiesOptions(false, false, true);
2727
private Boolean calculateConfidence;
28+
private Boolean calculateSalience;
2829
private Boolean linkEntities;
2930

3031
/**
@@ -33,8 +34,9 @@ public final class EntitiesOptions extends Options {
3334
* @param calculateConfidence return confidence score for the extraction.
3435
* @param linkEntities perform entity linking in addition to extraction.
3536
*/
36-
protected EntitiesOptions(Boolean calculateConfidence, Boolean linkEntities) {
37+
protected EntitiesOptions(Boolean calculateConfidence, Boolean calculateSalience, Boolean linkEntities) {
3738
this.calculateConfidence = calculateConfidence;
39+
this.calculateSalience = calculateSalience;
3840
this.linkEntities = linkEntities;
3941
}
4042

@@ -52,6 +54,13 @@ public Boolean getCalculateConfidence() {
5254
return calculateConfidence;
5355
}
5456

57+
/**
58+
* @return the calculateSalience flag.
59+
*/
60+
public Boolean getCalculateSalience() {
61+
return calculateSalience;
62+
}
63+
5564
@Override
5665
public boolean equals(Object o) {
5766
if (this == o) {
@@ -62,16 +71,18 @@ public boolean equals(Object o) {
6271
}
6372
EntitiesOptions that = (EntitiesOptions) o;
6473
return Objects.equals(linkEntities, that.linkEntities)
65-
&& Objects.equals(calculateConfidence, that.calculateConfidence);
74+
&& Objects.equals(calculateConfidence, that.calculateConfidence)
75+
&& Objects.equals(calculateSalience, that.calculateSalience);
6676
}
6777

6878
@Override
6979
public int hashCode() {
70-
return Objects.hash(calculateConfidence, linkEntities);
80+
return Objects.hash(calculateConfidence, calculateSalience, linkEntities);
7181
}
7282

7383
public static class Builder {
7484
private Boolean calculateConfidence;
85+
private Boolean calculateSalience;
7586
private Boolean linkEntities;
7687

7788
public Builder() {
@@ -89,6 +100,17 @@ public Builder calculateConfidence(Boolean calculateConfidence) {
89100
return this;
90101
}
91102

103+
/**
104+
* DocumentRequest calculate salience score. If the value is {@code true}, then the endpoint will
105+
* return salience scores. If {@code false} or {@code null}, not.
106+
* @param calculateSalience whether to get salience score.
107+
* @return this.
108+
*/
109+
public Builder calculateSalience(Boolean calculateSalience) {
110+
this.calculateSalience = calculateSalience;
111+
return this;
112+
}
113+
92114
/**
93115
* DocumentRequest entity linking. If the value is {@code true}, then the the endpoint will link entities to the
94116
* knowledge base. If {@code false}, not. If {@code null}, the endpoint will perform default processing.
@@ -101,7 +123,7 @@ public Builder linkEntities(Boolean linkEntities) {
101123
}
102124

103125
public EntitiesOptions build() {
104-
return new EntitiesOptions(calculateConfidence, linkEntities);
126+
return new EntitiesOptions(calculateConfidence, calculateSalience, linkEntities);
105127
}
106128
}
107129
}

model/src/main/java/com/basistech/rosette/apimodel/EntityMention.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class EntityMention {
7272
* @return the confidence score for the entity (0.0-1.0)
7373
*/
7474
private final Double confidence;
75+
private final Double salience;
7576

7677
/**
7778
* constructor for {@code EntityMention}
@@ -81,6 +82,7 @@ public class EntityMention {
8182
* @param normalized normalized mention text
8283
* @param count mention count
8384
* @param entityId if the entity was linked, the ID from the knowledge base.
85+
* @param confidence entity confidence
8486
*/
8587
@Deprecated
8688
public EntityMention(
@@ -92,7 +94,7 @@ public EntityMention(
9294
String entityId,
9395
Double confidence
9496
) {
95-
this(type, mention, normalized, count, null, entityId, confidence);
97+
this(type, mention, normalized, count, null, entityId, confidence, null);
9698
}
9799

98100
/**
@@ -102,6 +104,7 @@ public EntityMention(
102104
* @param normalized normalized mention text
103105
* @param entityId if the entity was linked, the ID from the knowledge base.
104106
* @param count mention count
107+
* @param confidence entity confidence
105108
*/
106109
@Deprecated
107110
public EntityMention(
@@ -112,7 +115,7 @@ public EntityMention(
112115
Integer count,
113116
Double confidence
114117
) {
115-
this(type, mention, normalized, count, null, entityId, confidence);
118+
this(type, mention, normalized, count, null, entityId, confidence, null);
116119
}
117120

118121
/**
@@ -132,7 +135,8 @@ public EntityMention(
132135
Integer count,
133136
List<MentionOffsets> mentionOffsets,
134137
String entityId,
135-
Double confidence
138+
Double confidence,
139+
Double salience
136140
) {
137141
this.indocChainId = null;
138142
this.type = type;
@@ -142,5 +146,28 @@ public EntityMention(
142146
this.count = count;
143147
this.mentionOffsets = mentionOffsets;
144148
this.confidence = confidence;
149+
this.salience = salience;
150+
}
151+
152+
/**
153+
* constructor for {@code EntityMention}
154+
* @param type entity type
155+
* @param mention mention text
156+
* @param normalized normalized mention text
157+
* @param entityId if the entity was linked, the ID from the knowledge base.
158+
* @param count mention count
159+
* @param confidence entity confidence
160+
* @param salience entity salience
161+
*/
162+
public EntityMention(
163+
String type,
164+
String mention,
165+
String normalized,
166+
String entityId,
167+
Integer count,
168+
Double confidence,
169+
Double salience
170+
) {
171+
this(type, mention, normalized, count, null, entityId, confidence, salience);
145172
}
146173
}

model/src/main/java/com/basistech/rosette/apimodel/EntitySentiment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public EntitySentiment(String type,
5252
String entityId,
5353
Double confidence,
5454
Label sentiment) {
55-
this(type, mention, normalized, count, null, entityId, confidence, sentiment);
55+
this(type, mention, normalized, count, null, entityId, confidence, null, sentiment);
5656
}
5757

5858
/**
@@ -73,8 +73,9 @@ public EntitySentiment(String type,
7373
List<MentionOffsets> mentionOffsets,
7474
String entityId,
7575
Double confidence,
76+
Double salience,
7677
Label sentiment) {
77-
super(type, mention, normalized, count, mentionOffsets, entityId, confidence);
78+
super(type, mention, normalized, count, mentionOffsets, entityId, confidence, salience);
7879
this.sentiment = sentiment;
7980
}
8081
}

model/src/main/java/com/basistech/rosette/apimodel/SentimentOptions.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@
2222
* Sentiment options.
2323
*/
2424
public final class SentimentOptions extends Options {
25-
public static final SentimentOptions DEGAULT_OPTIONS = new SentimentOptions(false);
25+
public static final SentimentOptions DEGAULT_OPTIONS = new SentimentOptions(false, false);
2626
private Boolean calculateEntityConfidence;
27+
private Boolean calculateEntitySalience;
2728

2829
/**
2930
* Constructor for {@code SentimentOptions}
3031
*
3132
* @param calculateEntityConfidence return confidence score for the entities.
3233
*/
33-
protected SentimentOptions(Boolean calculateEntityConfidence) {
34+
protected SentimentOptions(Boolean calculateEntityConfidence, Boolean calculateEntitySalience) {
3435
this.calculateEntityConfidence = calculateEntityConfidence;
36+
this.calculateEntitySalience = calculateEntitySalience;
3537
}
3638

3739
/**
@@ -41,6 +43,13 @@ public Boolean getCalculateEntityConfidence() {
4143
return calculateEntityConfidence;
4244
}
4345

46+
/**
47+
* @return the calculateEntitySalience flag.
48+
*/
49+
public Boolean getCalculateEntitySalience() {
50+
return calculateEntitySalience;
51+
}
52+
4453
@Override
4554
public boolean equals(Object o) {
4655
if (this == o) {
@@ -50,16 +59,18 @@ public boolean equals(Object o) {
5059
return false;
5160
}
5261
SentimentOptions that = (SentimentOptions)o;
53-
return Objects.equals(this.calculateEntityConfidence, that.calculateEntityConfidence);
62+
return Objects.equals(this.calculateEntityConfidence, that.calculateEntityConfidence)
63+
&& Objects.equals(this.calculateEntitySalience, that.calculateEntitySalience);
5464
}
5565

5666
@Override
5767
public int hashCode() {
58-
return Objects.hash(calculateEntityConfidence);
68+
return Objects.hash(calculateEntityConfidence, calculateEntitySalience);
5969
}
6070

6171
public static class Builder {
6272
private Boolean calculateEntityConfidence;
73+
private Boolean calculateEntitySalience;
6374

6475
/**
6576
* DocumentRequest calculate entity confidence score. If the value is {@code true}, then the endpoint will
@@ -72,8 +83,19 @@ public Builder calculateEntityConfidence(Boolean calculateEntityConfidence) {
7283
return this;
7384
}
7485

86+
/**
87+
* DocumentRequest calculate entity salience score. If the value is {@code true}, then the endpoint will
88+
* return salience scores. If {@code false} or {@code null}, not.
89+
* @param calculateEntitySalience whether to get entity salience score.
90+
* @return this.
91+
*/
92+
public Builder calculateEntitySalience(Boolean calculateEntitySalience) {
93+
this.calculateEntitySalience = calculateEntitySalience;
94+
return this;
95+
}
96+
7597
public SentimentOptions build() {
76-
return new SentimentOptions(calculateEntityConfidence);
98+
return new SentimentOptions(calculateEntityConfidence, calculateEntitySalience);
7799
}
78100
}
79101
}

0 commit comments

Comments
 (0)