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

Commit 4459b7b

Browse files
authored
clicking on weak supervision results adds them to manual label set (#57)
1 parent 2f91186 commit 4459b7b

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ <h1 class="text-lg text-gray-900 mb-2">Warning
277277
<ng-template
278278
[ngIf]="rla.sourceType == LabelSourceType.WEAK_SUPERVISION"
279279
[ngIfElse]="displayCallback">
280-
<div class="text-sm font-medium mr-3 px-2 py-0.5 rounded-md border border-dotted mr-2 pr-0.5 cursor-default"
280+
<div class="cursor-pointer text-sm font-medium mr-3 px-2 py-0.5 rounded-md border border-dotted mr-2 pr-0.5 cursor-default"
281+
(click)="addLabelToTask(task.id, rla.labelingTaskLabel.id)"
281282
[ngClass]="[getBackground(rla.labelingTaskLabel.color), getText(rla.labelingTaskLabel.color), getBorder(rla.labelingTaskLabel.color)]">
282283
<svg xmlns="http://www.w3.org/2000/svg"
283284
class="inline-block icon icon-tabler icon-tabler-assembly"
@@ -807,11 +808,13 @@ <h1 class="text-lg text-gray-900 mb-2">Delete record</h1>
807808
<div *ngIf="overlayData && overlayData.isFirst" class="w-0 h-14 relative">
808809
<div class="absolute bottom-3">
809810
<div hover-group-class="hover_child_hover" [hover-group]="overlayData.group"
810-
class="absolute w-0 hover_child " style="bottom: 0;left:3px">
811+
class="absolute w-0 hover_child " style="bottom: 0;left:3px"
812+
(click)="addLabelToMarkedTextFromSuggestion(overlayData)">
813+
811814
<div class="relative" style="z-index:2">
812815
<label
813816
[ngClass]="[getBackground(overlayData.labelColor), getText(overlayData.labelColor), getBorder(overlayData.labelColor), getHover(overlayData.labelColor)]"
814-
class="rounded-lg font-medium px-1 normal-case whitespace-nowrap">{{overlayData.labelDisplay}}</label>
817+
class="cursor-pointer rounded-lg font-medium px-1 normal-case whitespace-nowrap">{{overlayData.labelDisplay}}</label>
815818
</div>
816819
</div>
817820
</div>

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,13 @@ export class LabelingComponent implements OnInit, OnDestroy {
775775
let overlayData = {
776776
token: token,
777777
group: key,
778+
tokenStartIdx: md.tokenStartIdx,
779+
tokenEndIdx: md.tokenEndIdx,
780+
value: md.value,
778781
isFirst: i == md.tokenStartIdx,
779782
isLast: i == md.tokenEndIdx,
780783
labelName: md.labelingTaskLabel.name,
784+
labelingTaskId: md.labelingTaskLabel.labelingTask.id,
781785
labelId: md.labelingTaskLabel.id,
782786
labelDisplay: this.getLabelForDisplay(
783787
md.labelingTaskLabel.name,
@@ -1389,7 +1393,31 @@ export class LabelingComponent implements OnInit, OnDestroy {
13891393
}
13901394
}
13911395

1396+
addLabelToMarkedTextFromSuggestion(overlayData) {
1397+
const dataEntry = {
1398+
startIdx: overlayData.tokenStartIdx,
1399+
endIdx: overlayData.tokenEndIdx,
1400+
value: overlayData.value,
1401+
};
1402+
1403+
this.somethingLoading = true;
1404+
this.recordApolloService
1405+
.addExtractionLabelToRecord(
1406+
this.project.id,
1407+
this.fullRecordData.id,
1408+
overlayData.labelingTaskId,
1409+
dataEntry.startIdx,
1410+
dataEntry.endIdx,
1411+
dataEntry.value,
1412+
overlayData.labelId,
1413+
this.displayUserId == this.GOLD_USER_ID ? true : null
1414+
)
1415+
.pipe(first())
1416+
.subscribe();
1417+
}
1418+
13921419
addLabelToMarkedText(taskId: string, labelId: string) {
1420+
13931421
if (!this.selectionJSON) return;
13941422
if (this.selectionJSON.error) return;
13951423

@@ -1420,7 +1448,7 @@ export class LabelingComponent implements OnInit, OnDestroy {
14201448
)
14211449
.pipe(first())
14221450
.subscribe();
1423-
1451+
14241452
}
14251453

14261454
addLabelToTask(labelingTaskId: string, labelId: string) {

0 commit comments

Comments
 (0)