@konfuzio/document-validation-ui 0.2.2-dev.2 → 0.2.2-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/package.json +1 -1
- package/src/components/App.vue +2 -0
- package/src/store/document.js +38 -35
package/package.json
CHANGED
package/src/components/App.vue
CHANGED
package/src/store/document.js
CHANGED
|
@@ -167,14 +167,14 @@ const getters = {
|
|
|
167
167
|
/* Returns the annotations ordered by highest confidence */
|
|
168
168
|
annotationsByConfidence: (state) => (annotations) => {
|
|
169
169
|
annotations.sort((a, b) => {
|
|
170
|
-
|
|
170
|
+
// in reverse, comparison was not working correctly in the correct way
|
|
171
|
+
if (a.confidence > b.confidence) {
|
|
171
172
|
return -1;
|
|
172
|
-
} else if (a.confidence
|
|
173
|
+
} else if (a.confidence < b.confidence) {
|
|
173
174
|
return 1;
|
|
174
175
|
}
|
|
175
176
|
return 0;
|
|
176
177
|
});
|
|
177
|
-
|
|
178
178
|
return annotations;
|
|
179
179
|
},
|
|
180
180
|
|
|
@@ -359,18 +359,6 @@ const getters = {
|
|
|
359
359
|
return false;
|
|
360
360
|
};
|
|
361
361
|
|
|
362
|
-
const sortByConfidenceOrByAnnotationSelected = (annotations) => {
|
|
363
|
-
annotations = getters.annotationsByConfidence(annotations);
|
|
364
|
-
if (state.annotationId) {
|
|
365
|
-
for (let i = 0; i < annotations.length; i++) {
|
|
366
|
-
if (state.annotationId == annotations[i].id) {
|
|
367
|
-
annotations.unshift(annotations.splice(i, 1)[0]);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
return annotations;
|
|
372
|
-
};
|
|
373
|
-
|
|
374
362
|
if (state.annotationSets) {
|
|
375
363
|
state.annotationSets.forEach((annotationSet) => {
|
|
376
364
|
labels = [];
|
|
@@ -390,13 +378,6 @@ const getters = {
|
|
|
390
378
|
!state.annotationFilters.showFeedbackNeeded ||
|
|
391
379
|
!state.annotationFilters.showAccepted
|
|
392
380
|
) {
|
|
393
|
-
if (!label.has_multiple_top_candidates) {
|
|
394
|
-
// if multi label = false, sort by confidence
|
|
395
|
-
label.annotations = sortByConfidenceOrByAnnotationSelected(
|
|
396
|
-
label.annotations
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
381
|
label.annotations.forEach((annotation) => {
|
|
401
382
|
if (
|
|
402
383
|
state.annotationFilters.showFeedbackNeeded &&
|
|
@@ -426,12 +407,6 @@ const getters = {
|
|
|
426
407
|
}
|
|
427
408
|
});
|
|
428
409
|
} else {
|
|
429
|
-
if (!label.has_multiple_top_candidates) {
|
|
430
|
-
// if multi label = false, sort by confidence
|
|
431
|
-
label.annotations = sortByConfidenceOrByAnnotationSelected(
|
|
432
|
-
label.annotations
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
410
|
// add annotations to the document array
|
|
436
411
|
label.annotations.forEach((annotation) => {
|
|
437
412
|
const added = addAnnotation(
|
|
@@ -478,6 +453,18 @@ const getters = {
|
|
|
478
453
|
let processedAnnotationSets = [];
|
|
479
454
|
let processedLabels = [];
|
|
480
455
|
|
|
456
|
+
const sortByConfidenceOrByAnnotationSelected = (annotations) => {
|
|
457
|
+
annotations = getters.annotationsByConfidence(annotations);
|
|
458
|
+
if (state.annotationId) {
|
|
459
|
+
for (let i = 0; i < annotations.length; i++) {
|
|
460
|
+
if (state.annotationId == annotations[i].id) {
|
|
461
|
+
annotations.unshift(annotations.splice(i, 1)[0]);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return annotations;
|
|
466
|
+
};
|
|
467
|
+
|
|
481
468
|
annotationSets.forEach((annotationSet) => {
|
|
482
469
|
// check if empty label sets and env variable set as true
|
|
483
470
|
if (
|
|
@@ -488,7 +475,7 @@ const getters = {
|
|
|
488
475
|
) {
|
|
489
476
|
labels = [];
|
|
490
477
|
annotationSet.labels.forEach((label) => {
|
|
491
|
-
|
|
478
|
+
let labelAnnotations = [];
|
|
492
479
|
|
|
493
480
|
// add annotations to the document array
|
|
494
481
|
// remove negative annotations
|
|
@@ -497,6 +484,13 @@ const getters = {
|
|
|
497
484
|
labelAnnotations.push(ann);
|
|
498
485
|
}
|
|
499
486
|
});
|
|
487
|
+
|
|
488
|
+
if (!label.has_multiple_top_candidates) {
|
|
489
|
+
// if multi label = false, sort by confidence
|
|
490
|
+
labelAnnotations =
|
|
491
|
+
sortByConfidenceOrByAnnotationSelected(labelAnnotations);
|
|
492
|
+
}
|
|
493
|
+
|
|
500
494
|
labels.push({ ...label, annotations: labelAnnotations });
|
|
501
495
|
processedLabels.push(label);
|
|
502
496
|
annotations.push(...labelAnnotations);
|
|
@@ -1621,6 +1615,7 @@ const actions = {
|
|
|
1621
1615
|
labelToFind.annotations.splice(i, 1)[0]
|
|
1622
1616
|
);
|
|
1623
1617
|
commit("SET_ANNOTATIONS_IN_LABEL", {
|
|
1618
|
+
annotationSet,
|
|
1624
1619
|
label: labelToFind,
|
|
1625
1620
|
annotations: labelToFind.annotations,
|
|
1626
1621
|
});
|
|
@@ -1638,16 +1633,22 @@ const actions = {
|
|
|
1638
1633
|
annotationSet.labels.forEach((labelToFind) => {
|
|
1639
1634
|
if (labelToFind.id === label.id) {
|
|
1640
1635
|
if (labelToFind.annotations && labelToFind.annotations.length > 1) {
|
|
1641
|
-
const
|
|
1642
|
-
|
|
1636
|
+
const cloneAnnotations = [...labelToFind.annotations];
|
|
1637
|
+
const firstElement = cloneAnnotations.shift();
|
|
1638
|
+
cloneAnnotations.push(firstElement);
|
|
1643
1639
|
commit("SET_ANNOTATIONS_IN_LABEL", {
|
|
1640
|
+
annotationSet,
|
|
1644
1641
|
label: labelToFind,
|
|
1645
|
-
annotations:
|
|
1642
|
+
annotations: cloneAnnotations,
|
|
1646
1643
|
});
|
|
1647
|
-
newFirstAnn =
|
|
1644
|
+
newFirstAnn = cloneAnnotations[0];
|
|
1645
|
+
return;
|
|
1648
1646
|
}
|
|
1649
1647
|
}
|
|
1650
1648
|
});
|
|
1649
|
+
if (newFirstAnn) {
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1651
1652
|
});
|
|
1652
1653
|
|
|
1653
1654
|
if (newFirstAnn) {
|
|
@@ -1806,10 +1807,12 @@ const mutations = {
|
|
|
1806
1807
|
SET_LABELS: (state, labels) => {
|
|
1807
1808
|
state.labels = labels;
|
|
1808
1809
|
},
|
|
1809
|
-
SET_ANNOTATIONS_IN_LABEL: (state, { label, annotations }) => {
|
|
1810
|
-
|
|
1810
|
+
SET_ANNOTATIONS_IN_LABEL: (state, { label, annotations, annotationSet }) => {
|
|
1811
|
+
annotationSet.labels.forEach((labelToFind) => {
|
|
1811
1812
|
if (labelToFind.id === label.id) {
|
|
1813
|
+
delete labelToFind.annotations;
|
|
1812
1814
|
labelToFind.annotations = annotations;
|
|
1815
|
+
return;
|
|
1813
1816
|
}
|
|
1814
1817
|
});
|
|
1815
1818
|
},
|