Skip to content

Commit 7764259

Browse files
Katsuya-TomiokaLi Xu
authored andcommitted
Tej 1058 linking confidence rosapi 1.8 (#110)
* TEJ-1058: added linkingConfidence to EntityMention * TEJ-1058: test data
1 parent c7edd4e commit 7764259

File tree

5 files changed

+66
-11
lines changed

5 files changed

+66
-11
lines changed

api/src/test/mock-data/response/eng-doc-entities.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"indocChainId": 2,
2020
"mention": "Afghanistan",
2121
"normalized": "Afghanistan",
22-
"type": "LOCATION"
22+
"type": "LOCATION",
23+
"salience": 1.0
2324
},
2425
{
2526
"count": 1,

api/src/test/mock-data/response/eng-doc-entities_linked.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
"confidence": 0.6191439548350202,
55
"entityId": "Q30",
66
"indocChainId": 0,
7-
"mention": "U.S."
7+
"mention": "U.S.",
8+
"linkingConfidence": 0.5
89
},
910
{
1011
"confidence": 0.1883195998298547,
1112
"entityId": "Q796",
1213
"indocChainId": 1,
13-
"mention": "Iraq"
14-
},
14+
"mention": "Iraq",
15+
"linkingConfidence": 0.5
16+
},
1517
{
1618
"confidence": 0.16953509200793812,
1719
"entityId": "Q889",
1820
"indocChainId": 2,
19-
"mention": "Afghanistan"
21+
"mention": "Afghanistan",
22+
"linkingConfidence": 0.5
2023
}
2124
]
22-
}
25+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public EntityMentionMixin(
2828
@JsonProperty("normalized") String normalized,
2929
@JsonProperty("count") Integer count,
3030
@JsonProperty("entityId") String entityId,
31-
@JsonProperty("confidence") Double confidence
31+
@JsonProperty("confidence") Double confidence,
32+
@JsonProperty("salience") Double salience,
33+
@JsonProperty("linkingConfidence") Double linkingConfidence
3234
) {
3335
//
3436
}

json/src/test/data/EntitiesResponse.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"indocChainId": 0,
66
"mention": "Samsung",
77
"normalized": "Samsung",
8-
"type": "ORGANIZATION"
8+
"type": "ORGANIZATION",
9+
"salience": 1.0,
10+
"confidence": 1.0,
11+
"linkingConfidence": 1.0
912
}
1013
]
1114
}

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

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public final class EntityMention {
3232
private final String entityId;
3333
private final Double confidence;
3434
private final Double salience;
35+
private final Double linkingConfidence;
3536

3637
/**
3738
* constructor for {@code EntityMention}
@@ -61,6 +62,7 @@ public EntityMention(
6162
this.entityId = entityId;
6263
this.confidence = confidence;
6364
this.salience = null;
65+
this.linkingConfidence = null;
6466
}
6567

6668
/**
@@ -88,6 +90,7 @@ public EntityMention(
8890
this.count = count;
8991
this.confidence = confidence;
9092
this.salience = null;
93+
this.linkingConfidence = null;
9194
}
9295

9396
/**
@@ -117,6 +120,40 @@ public EntityMention(
117120
this.count = count;
118121
this.confidence = confidence;
119122
this.salience = salience;
123+
this.linkingConfidence = null;
124+
}
125+
126+
/**
127+
* constructor for {@code EntityMention}
128+
* @param indocChainId in-document entity chain id
129+
* @param type entity type
130+
* @param mention mention text
131+
* @param normalized normalized mention text
132+
* @param count mention count
133+
* @param entityId if the entity was linked, the ID from the knowledge base.
134+
* @param confidence entity confidence
135+
*/
136+
@Deprecated
137+
public EntityMention(
138+
Integer indocChainId,
139+
String type,
140+
String mention,
141+
String normalized,
142+
Integer count,
143+
String entityId,
144+
Double confidence,
145+
Double salience,
146+
Double linkingConfidence
147+
) {
148+
this.indocChainId = indocChainId;
149+
this.type = type;
150+
this.mention = mention;
151+
this.normalized = normalized;
152+
this.count = count;
153+
this.entityId = entityId;
154+
this.confidence = confidence;
155+
this.salience = salience;
156+
this.linkingConfidence = linkingConfidence;
120157
}
121158

122159
/**
@@ -180,12 +217,20 @@ public Double getConfidence() {
180217

181218
/**
182219
* get the salience score for the entity.
183-
* @return the salience score (0.0-1.0)
220+
* @return the salience score (0.0 or 1.0)
184221
*/
185222
public Double getSalience() {
186223
return salience;
187224
}
188225

226+
/**
227+
* get the linking confidence score for the entity.
228+
* @return the linking confidence score (0.0-1.0)
229+
*/
230+
public Double getLinkingConfidence() {
231+
return linkingConfidence;
232+
}
233+
189234
@Override
190235
public boolean equals(Object o) {
191236
if (this == o) {
@@ -202,11 +247,12 @@ public boolean equals(Object o) {
202247
&& Objects.equals(count, that.count)
203248
&& Objects.equals(entityId, that.entityId)
204249
&& Objects.equals(confidence, that.confidence)
205-
&& Objects.equals(salience, that.salience);
250+
&& Objects.equals(salience, that.salience)
251+
&& Objects.equals(linkingConfidence, that.linkingConfidence);
206252
}
207253

208254
@Override
209255
public int hashCode() {
210-
return Objects.hash(indocChainId, type, mention, normalized, count, entityId, confidence, salience);
256+
return Objects.hash(indocChainId, type, mention, normalized, count, entityId, confidence, salience, linkingConfidence);
211257
}
212258
}

0 commit comments

Comments
 (0)