Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit 1fd874d

Browse files
committed
annotator manual labels as information source
1 parent bc273e6 commit 1fd874d

File tree

4 files changed

+45
-26
lines changed

4 files changed

+45
-26
lines changed

src/app/base/services/record/record-apollo.service.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ export class RecordApolloService {
187187
recordId: string,
188188
labelingTaskId: string,
189189
labelId: string,
190-
asGoldStar: boolean = null
190+
asGoldStar: boolean = null,
191+
sourceId: string = null,
191192
): Observable<any> {
192193
return this.apollo.mutate({
193194
mutation: mutations.ADD_CLASSIFICATION_LABELS_TO_RECORD,
@@ -196,7 +197,8 @@ export class RecordApolloService {
196197
recordId: recordId,
197198
labelingTaskId: labelingTaskId,
198199
labelId: labelId,
199-
asGoldStar: asGoldStar
200+
asGoldStar: asGoldStar,
201+
sourceId: sourceId
200202
},
201203
refetchQueries: [
202204
{
@@ -224,7 +226,8 @@ export class RecordApolloService {
224226
endIdx: number,
225227
value: string,
226228
labelId: string,
227-
asGoldStar: boolean = null
229+
asGoldStar: boolean = null,
230+
sourceId: string = null,
228231
): Observable<any> {
229232
return this.apollo.mutate({
230233
mutation: mutations.ADD_EXTRACTION_LABEL_TO_RECORD,
@@ -236,7 +239,8 @@ export class RecordApolloService {
236239
tokenEndIndex: endIdx,
237240
value: value,
238241
labelId: labelId,
239-
asGoldStar: asGoldStar
242+
asGoldStar: asGoldStar,
243+
sourceId: sourceId,
240244
},
241245
refetchQueries: [
242246
{

src/app/base/services/record/record-mutations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { gql } from 'apollo-angular';
22

33
export const mutations = {
44
ADD_CLASSIFICATION_LABELS_TO_RECORD: gql`
5-
mutation ($projectId: ID!, $recordId: ID!, $labelingTaskId: ID, $labelId: ID, $asGoldStar:Boolean) {
6-
addClassificationLabelsToRecord(projectId: $projectId, recordId: $recordId, labelingTaskId: $labelingTaskId, labelId: $labelId,asGoldStar:$asGoldStar) {
5+
mutation ($projectId: ID!, $recordId: ID!, $labelingTaskId: ID, $labelId: ID, $asGoldStar:Boolean, $sourceId: ID) {
6+
addClassificationLabelsToRecord(projectId: $projectId, recordId: $recordId, labelingTaskId: $labelingTaskId, labelId: $labelId,asGoldStar:$asGoldStar, sourceId: $sourceId) {
77
ok
88
}
99
}
1010
`,
1111

1212
ADD_EXTRACTION_LABEL_TO_RECORD: gql`
13-
mutation ($projectId: ID!, $recordId: ID!, $labelingTaskId: ID!, $tokenStartIndex: Int!, $tokenEndIndex: Int!, $value: String!, $labelId: ID!, $asGoldStar:Boolean) {
14-
addExtractionLabelToRecord(projectId: $projectId, recordId: $recordId, labelingTaskId: $labelingTaskId, tokenStartIndex: $tokenStartIndex, tokenEndIndex: $tokenEndIndex, value: $value, labelId: $labelId,asGoldStar:$asGoldStar) {
13+
mutation ($projectId: ID!, $recordId: ID!, $labelingTaskId: ID!, $tokenStartIndex: Int!, $tokenEndIndex: Int!, $value: String!, $labelId: ID!, $asGoldStar:Boolean, $sourceId: ID) {
14+
addExtractionLabelToRecord(projectId: $projectId, recordId: $recordId, labelingTaskId: $labelingTaskId, tokenStartIndex: $tokenStartIndex, tokenEndIndex: $tokenEndIndex, value: $value, labelId: $labelId,asGoldStar:$asGoldStar, sourceId: $sourceId) {
1515
ok
1616
}
1717
}

src/app/labeling/components/labeling.component.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,15 @@ <h1 class="text-lg text-gray-900 mb-2">Warning
267267
class="max-w-xxs truncate mx-1">{{task.name}}</span>
268268
<span>options</span>
269269
</button>
270-
271270
</div>
272271
<div>
273-
274272
<ng-template ngFor let-rla [ngForOf]="taskLabels">
275-
<div *ngIf="rla.sourceType != LabelSourceType.INFORMATION_SOURCE || (rla.sourceType == LabelSourceType.INFORMATION_SOURCE && showInformationSourcesFlag)"
273+
<div *ngIf="rla.sourceType != LabelSourceType.INFORMATION_SOURCE || (rla.sourceType == LabelSourceType.INFORMATION_SOURCE && showInformationSourcesFlag) || rla.sourceId == sourceId"
276274
[attr.data-tip]="rla.dataTip"
277275
class="tooltip table"
278276
[ngClass]="(displayUserId == GOLD_USER_ID || displayUserId == user.id)?'mt-3':null">
279277
<ng-template
280-
[ngIf]="rla.sourceType != LabelSourceType.MANUAL"
278+
[ngIf]="rla.sourceType != LabelSourceType.MANUAL && rla.sourceId != sourceId"
281279
[ngIfElse]="displayNormalLabel">
282280
<ng-template
283281
[ngIf]="rla.sourceType == LabelSourceType.WEAK_SUPERVISION"

src/app/labeling/components/labeling.component.ts

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class LabelingComponent implements OnInit, OnDestroy {
6262
dataSliceQuery$: any;
6363
dataSlices$: any;
6464

65+
sourceId: string; // if the session is from an annotator heuristic
66+
6567
user: any;
6668
displayUserId: any;
6769
rlaGroupMap: Map<string, any[]> = new Map<string, any[]>();
@@ -155,9 +157,6 @@ export class LabelingComponent implements OnInit, OnDestroy {
155157
// });
156158
//check id type
157159

158-
159-
console.log("init")
160-
161160
let initialTasks$ = [];
162161
initialTasks$.push(this.prepareUser());
163162
forkJoin(initialTasks$).pipe(first()).subscribe(() => {
@@ -172,10 +171,6 @@ export class LabelingComponent implements OnInit, OnDestroy {
172171
//wait for preparation tasks to finish
173172
forkJoin(initialTasks$).pipe(first()).subscribe(() => this.verifyAndHandleQueryParams(this.labelingLinkData.projectId));
174173
});
175-
176-
177-
178-
179174
}
180175

181176
private initialSetupNoWait() {
@@ -230,6 +225,7 @@ export class LabelingComponent implements OnInit, OnDestroy {
230225
.pipe(first())
231226
.subscribe();
232227
}
228+
233229
//default handling
234230
if (pos == null && this.huddleData?.linkData.requestedPos) pos = this.huddleData.linkData.requestedPos;
235231
if (pos == null) pos = 0;
@@ -249,6 +245,8 @@ export class LabelingComponent implements OnInit, OnDestroy {
249245
if (this.huddleData) this.jumpToPosition(projectId, pos);
250246

251247
this.sessionRequested = true;
248+
249+
this.sourceId = this.inferSourceID()
252250
}
253251

254252
requestHuddleData(projectId: string, sessionId: string) {
@@ -1482,13 +1480,21 @@ export class LabelingComponent implements OnInit, OnDestroy {
14821480
dataEntry.endIdx,
14831481
dataEntry.value,
14841482
labelId,
1485-
this.displayUserId == this.GOLD_USER_ID ? true : null
1483+
this.displayUserId == this.GOLD_USER_ID ? true : null,
1484+
this.inferSourceID(),
14861485
)
14871486
.pipe(first())
14881487
.subscribe();
14891488

14901489
}
14911490

1491+
inferSourceID() {
1492+
const labelingUrlFull = this.activatedRoute.snapshot['_routerState'].url;
1493+
const typeIndex = /\&type/.exec(labelingUrlFull).index;
1494+
const type = labelingUrlFull.substring(typeIndex + 6); // get rid of "?type=" (6 chars)
1495+
return type == "HEURISTIC" ? this.huddleData.linkData.id : null;
1496+
}
1497+
14921498
addLabelToTask(labelingTaskId: string, labelId: string) {
14931499
let existingLabels = this.fullRecordData.recordLabelAssociations.filter(
14941500
(e) => e.sourceType == LabelSource.MANUAL && e.labelingTaskLabel.labelingTask.id == labelingTaskId
@@ -1503,7 +1509,8 @@ export class LabelingComponent implements OnInit, OnDestroy {
15031509
this.fullRecordData.id,
15041510
labelingTaskId,
15051511
labelId,
1506-
this.displayUserId == this.GOLD_USER_ID ? true : null
1512+
this.displayUserId == this.GOLD_USER_ID ? true : null,
1513+
this.inferSourceID(),
15071514
)
15081515
.pipe(first())
15091516
.subscribe();
@@ -1574,11 +1581,21 @@ export class LabelingComponent implements OnInit, OnDestroy {
15741581
if (!this.fullRecordData) return [];
15751582
let found = [];
15761583
for (let rla of this.fullRecordData.recordLabelAssociations) {
1577-
if (
1578-
rla.labelingTaskLabel.labelingTask.id == taskId &&
1579-
rla.sourceType != LabelSource.INFORMATION_SOURCE
1580-
)
1581-
found.push(rla);
1584+
if (this.sourceId == null) {
1585+
if (
1586+
rla.labelingTaskLabel.labelingTask.id == taskId &&
1587+
rla.sourceType != LabelSource.INFORMATION_SOURCE
1588+
)
1589+
found.push(rla);
1590+
} else {
1591+
if (
1592+
rla.labelingTaskLabel.labelingTask.id == taskId &&
1593+
rla.sourceType == LabelSource.INFORMATION_SOURCE &&
1594+
rla.sourceId == this.sourceId
1595+
)
1596+
found.push(rla);
1597+
}
1598+
15821599
}
15831600
return found;
15841601
}

0 commit comments

Comments
 (0)