|
|
@ -64,6 +64,8 @@ class TestExportCategory(TestExport): |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="example2") |
|
|
|
self.category1 = mommy.make("ExportedCategory", example=self.example1, user=self.project.admin) |
|
|
|
self.category2 = mommy.make("ExportedCategory", example=self.example1, user=self.project.annotator) |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
|
self.data1 = self.data_to_text(self.example1) |
|
|
|
self.data2 = self.data_to_text(self.example2) |
|
|
@ -73,16 +75,16 @@ class TestExportCategory(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.category1.to_string()]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.category1.to_string()], "Comments": [self.comment1.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "label": []}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [], "Comments": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{**self.data1, "label": [self.category2.to_string()]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.category2.to_string()], "Comments": [self.comment2.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -95,15 +97,20 @@ class TestExportCategory(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.category1.to_string(), self.category2.to_string()]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
|
def test_confirmed_and_non_collaborative(self): |
|
|
|
self.prepare_data() |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = {self.project.admin.username: [{**self.data1, "label": [self.category1.to_string()]}]} |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.category1.to_string()], "Comments": [self.comment1.to_string()]} |
|
|
|
] |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
|
self.assertEqual(datasets[username], dataset) |
|
|
|
|
|
|
@ -114,6 +121,7 @@ class TestExportCategory(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.category1.to_string(), self.category2.to_string()]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -126,6 +134,8 @@ class TestExportSeq2seq(TestExport): |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.text1 = mommy.make("TextLabel", example=self.example1, user=self.project.admin) |
|
|
|
self.text2 = mommy.make("TextLabel", example=self.example1, user=self.project.annotator) |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
|
self.data1 = self.data_to_text(self.example1) |
|
|
|
self.data2 = self.data_to_text(self.example2) |
|
|
@ -135,16 +145,16 @@ class TestExportSeq2seq(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.text1.text]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.text1.text], "Comments": [self.comment1.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "label": []}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [], "Comments": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{**self.data1, "label": [self.text2.text]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.text2.text], "Comments": [self.comment2.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -157,8 +167,9 @@ class TestExportSeq2seq(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.text1.text, self.text2.text]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
@ -167,7 +178,7 @@ class TestExportSeq2seq(TestExport): |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.text1.text]}, |
|
|
|
{**self.data1, "label": [self.text1.text], "Comments": [self.comment1.to_string()]}, |
|
|
|
], |
|
|
|
self.project.approver.username: [], |
|
|
|
self.project.annotator.username: [], |
|
|
@ -182,6 +193,7 @@ class TestExportSeq2seq(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.text1.text, self.text2.text]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -194,6 +206,8 @@ class TestExportIntentDetectionAndSlotFilling(TestExport): |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.category1 = mommy.make("ExportedCategory", example=self.example1, user=self.project.admin) |
|
|
|
self.category2 = mommy.make("ExportedCategory", example=self.example1, user=self.project.annotator) |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
self.span = mommy.make( |
|
|
|
"ExportedSpan", example=self.example1, user=self.project.admin, start_offset=0, end_offset=1 |
|
|
|
) |
|
|
@ -210,20 +224,22 @@ class TestExportIntentDetectionAndSlotFilling(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [list(self.span.to_tuple())], |
|
|
|
"cats": [self.category1.to_string()], |
|
|
|
"Comments": [self.comment1.to_string()], |
|
|
|
}, |
|
|
|
{**self.data2, "entities": [], "cats": []}, |
|
|
|
{**self.data2, "entities": [], "cats": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"entities": [], |
|
|
|
"cats": [self.category2.to_string()], |
|
|
|
"Comments": [self.comment2.to_string()], |
|
|
|
}, |
|
|
|
{**self.data2, "entities": [], "cats": []}, |
|
|
|
{**self.data2, "entities": [], "cats": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "entities": [], "cats": []}, |
|
|
|
{**self.data2, "entities": [], "cats": []}, |
|
|
|
{**self.data1, "entities": [], "cats": [], "Comments": []}, |
|
|
|
{**self.data2, "entities": [], "cats": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -237,8 +253,9 @@ class TestExportIntentDetectionAndSlotFilling(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [list(self.span.to_tuple())], |
|
|
|
"cats": sorted([self.category1.to_string(), self.category2.to_string()]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, "entities": [], "cats": []}, |
|
|
|
{**self.data2, "entities": [], "cats": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
@ -251,6 +268,7 @@ class TestExportIntentDetectionAndSlotFilling(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [list(self.span.to_tuple())], |
|
|
|
"cats": [self.category1.to_string()], |
|
|
|
"Comments": [self.comment1.to_string()], |
|
|
|
}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [], |
|
|
@ -267,6 +285,7 @@ class TestExportIntentDetectionAndSlotFilling(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [list(self.span.to_tuple())], |
|
|
|
"cats": sorted([self.category1.to_string(), self.category2.to_string()]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -284,6 +303,8 @@ class TestExportSequenceLabeling(TestExport): |
|
|
|
) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
self.data1 = self.data_to_text(self.example1) |
|
|
|
self.data2 = self.data_to_text(self.example2) |
|
|
|
|
|
|
@ -292,16 +313,16 @@ class TestExportSequenceLabeling(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [list(self.span1.to_tuple())]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [list(self.span1.to_tuple())], "Comments": [self.comment1.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{**self.data1, "label": [list(self.span2.to_tuple())]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [list(self.span2.to_tuple())], "Comments": [self.comment2.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "label": []}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [], "Comments": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -314,8 +335,9 @@ class TestExportSequenceLabeling(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": [list(self.span1.to_tuple()), list(self.span2.to_tuple())], |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
@ -324,7 +346,7 @@ class TestExportSequenceLabeling(TestExport): |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [list(self.span1.to_tuple())]}, |
|
|
|
{**self.data1, "label": [list(self.span1.to_tuple())], "Comments": [self.comment1.to_string()]}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [], |
|
|
|
self.project.approver.username: [], |
|
|
@ -339,6 +361,7 @@ class TestExportSequenceLabeling(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": [list(self.span1.to_tuple()), list(self.span2.to_tuple())], |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -351,6 +374,8 @@ class TestExportSpeechToText(TestExport): |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.text1 = mommy.make("TextLabel", example=self.example1, user=self.project.admin) |
|
|
|
self.text2 = mommy.make("TextLabel", example=self.example1, user=self.project.annotator) |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
|
self.data1 = self.data_to_filename(self.example1) |
|
|
|
self.data2 = self.data_to_filename(self.example2) |
|
|
@ -360,16 +385,16 @@ class TestExportSpeechToText(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.text1.text]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.text1.text], "Comments": [self.comment1.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "label": []}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [], "Comments": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{**self.data1, "label": [self.text2.text]}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.text2.text], "Comments": [self.comment2.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -382,8 +407,9 @@ class TestExportSpeechToText(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.text1.text, self.text2.text]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
@ -392,7 +418,7 @@ class TestExportSpeechToText(TestExport): |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.text1.text]}, |
|
|
|
{**self.data1, "label": [self.text1.text], "Comments": [self.comment1.to_string()]}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [], |
|
|
|
self.project.approver.username: [], |
|
|
@ -407,6 +433,7 @@ class TestExportSpeechToText(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.text1.text, self.text2.text]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -419,6 +446,8 @@ class TestExportImageClassification(TestExport): |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.category1 = mommy.make("ExportedCategory", example=self.example1, user=self.project.admin) |
|
|
|
self.category2 = mommy.make("ExportedCategory", example=self.example1, user=self.project.annotator) |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
|
self.data1 = self.data_to_filename(self.example1) |
|
|
|
self.data2 = self.data_to_filename(self.example2) |
|
|
@ -428,22 +457,16 @@ class TestExportImageClassification(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": [self.category1.to_string()], |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.category1.to_string()], "Comments": [self.comment1.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "label": []}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [], "Comments": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": [self.category2.to_string()], |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data1, "label": [self.category2.to_string()], "Comments": [self.comment2.to_string()]}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -456,15 +479,20 @@ class TestExportImageClassification(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.category1.to_string(), self.category2.to_string()]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, "label": []}, |
|
|
|
{**self.data2, "label": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
|
def test_confirmed_and_non_collaborative(self): |
|
|
|
self.prepare_data() |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = {self.project.admin.username: [{**self.data1, "label": [self.category1.to_string()]}]} |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "label": [self.category1.to_string()], "Comments": [self.comment1.to_string()]} |
|
|
|
] |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
|
self.assertEqual(datasets[username], dataset) |
|
|
|
|
|
|
@ -475,6 +503,7 @@ class TestExportImageClassification(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"label": sorted([self.category1.to_string(), self.category2.to_string()]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -485,6 +514,8 @@ class TestExportBoundingBox(TestExport): |
|
|
|
self.project = prepare_project(BOUNDING_BOX, collaborative_annotation=collaborative) |
|
|
|
self.example1 = mommy.make("ExportedExample", project=self.project.item, text="confirmed") |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
self.bbox1 = mommy.make( |
|
|
|
"ExportedBoundingBox", example=self.example1, user=self.project.admin, x=0, y=0, width=10, height=10 |
|
|
|
) |
|
|
@ -503,19 +534,17 @@ class TestExportBoundingBox(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"bbox": [self.bbox1.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, "bbox": []}, |
|
|
|
{**self.data2, "bbox": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "bbox": []}, |
|
|
|
{**self.data2, "bbox": []}, |
|
|
|
{**self.data1, "bbox": [], "Comments": []}, |
|
|
|
{**self.data2, "bbox": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"bbox": [self.bbox2.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, "bbox": []}, |
|
|
|
{**self.data1, "bbox": [self.bbox2.to_dict()], "Comments": [self.comment2.to_dict()]}, |
|
|
|
{**self.data2, "bbox": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -528,15 +557,20 @@ class TestExportBoundingBox(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"bbox": [self.bbox1.to_dict(), self.bbox2.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict(), self.comment2.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, "bbox": []}, |
|
|
|
{**self.data2, "bbox": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
|
def test_confirmed_and_non_collaborative(self): |
|
|
|
self.prepare_data() |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = {self.project.admin.username: [{**self.data1, "bbox": [self.bbox1.to_dict()]}]} |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, "bbox": [self.bbox1.to_dict()], "Comments": [self.comment1.to_dict()]} |
|
|
|
] |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
|
self.assertEqual(datasets[username], dataset) |
|
|
|
|
|
|
@ -547,6 +581,7 @@ class TestExportBoundingBox(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"bbox": [self.bbox1.to_dict(), self.bbox2.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict(), self.comment2.to_dict()], |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -557,6 +592,8 @@ class TestExportSegmentation(TestExport): |
|
|
|
self.project = prepare_project(SEGMENTATION, collaborative_annotation=collaborative) |
|
|
|
self.example1 = mommy.make("ExportedExample", project=self.project.item, text="confirmed") |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
self.seg1 = mommy.make("ExportedSegmentation", example=self.example1, user=self.project.admin, points=[0, 1]) |
|
|
|
self.seg2 = mommy.make( |
|
|
|
"ExportedSegmentation", example=self.example1, user=self.project.annotator, points=[1, 2] |
|
|
@ -571,22 +608,16 @@ class TestExportSegmentation(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
self.column: [self.seg1.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data1, self.column: [self.seg1.to_dict()], "Comments": [self.comment1.to_dict()]}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, self.column: []}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data1, self.column: [], "Comments": []}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
self.column: [self.seg2.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data1, self.column: [self.seg2.to_dict()], "Comments": [self.comment2.to_dict()]}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -599,15 +630,20 @@ class TestExportSegmentation(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
self.column: [self.seg1.to_dict(), self.seg2.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict(), self.comment2.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
|
def test_confirmed_and_non_collaborative(self): |
|
|
|
self.prepare_data() |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = {self.project.admin.username: [{**self.data1, self.column: [self.seg1.to_dict()]}]} |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, self.column: [self.seg1.to_dict()], "Comments": [self.comment1.to_dict()]} |
|
|
|
] |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
|
self.assertEqual(datasets[username], dataset) |
|
|
|
|
|
|
@ -618,6 +654,7 @@ class TestExportSegmentation(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
self.column: [self.seg1.to_dict(), self.seg2.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict(), self.comment2.to_dict()], |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -628,6 +665,8 @@ class TestExportImageCaptioning(TestExport): |
|
|
|
self.project = prepare_project(IMAGE_CAPTIONING, collaborative_annotation=collaborative) |
|
|
|
self.example1 = mommy.make("ExportedExample", project=self.project.item, text="confirmed") |
|
|
|
self.example2 = mommy.make("ExportedExample", project=self.project.item, text="unconfirmed") |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
self.text1 = mommy.make("TextLabel", example=self.example1, user=self.project.admin) |
|
|
|
self.text2 = mommy.make("TextLabel", example=self.example1, user=self.project.annotator) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
@ -640,16 +679,16 @@ class TestExportImageCaptioning(TestExport): |
|
|
|
datasets = self.export_dataset() |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, self.column: [self.text1.text]}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data1, self.column: [self.text1.text], "Comments": [self.comment1.to_string()]}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, self.column: []}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data1, self.column: [], "Comments": []}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{**self.data1, self.column: [self.text2.text]}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data1, self.column: [self.text2.text], "Comments": [self.comment2.to_string()]}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -662,8 +701,9 @@ class TestExportImageCaptioning(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
self.column: sorted([self.text1.text, self.text2.text]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
}, |
|
|
|
{**self.data2, self.column: []}, |
|
|
|
{**self.data2, self.column: [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
@ -672,7 +712,7 @@ class TestExportImageCaptioning(TestExport): |
|
|
|
datasets = self.export_dataset(confirmed_only=True) |
|
|
|
expected_datasets = { |
|
|
|
self.project.admin.username: [ |
|
|
|
{**self.data1, self.column: [self.text1.text]}, |
|
|
|
{**self.data1, self.column: [self.text1.text], "Comments": [self.comment1.to_string()]}, |
|
|
|
], |
|
|
|
self.project.approver.username: [], |
|
|
|
self.project.annotator.username: [], |
|
|
@ -687,6 +727,7 @@ class TestExportImageCaptioning(TestExport): |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
self.column: sorted([self.text1.text, self.text2.text]), |
|
|
|
"Comments": sorted([self.comment1.to_string(), self.comment2.to_string()]), |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
@ -709,6 +750,8 @@ class TestExportRelation(TestExport): |
|
|
|
self.relation = mommy.make( |
|
|
|
"ExportedRelation", from_id=self.span1, to_id=self.span2, example=self.example1, user=self.project.admin |
|
|
|
) |
|
|
|
self.comment1 = mommy.make("ExportedComment", example=self.example1, user=self.project.admin) |
|
|
|
self.comment2 = mommy.make("ExportedComment", example=self.example1, user=self.project.annotator) |
|
|
|
mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin) |
|
|
|
self.data1 = self.data_to_text(self.example1) |
|
|
|
self.data2 = self.data_to_text(self.example2) |
|
|
@ -722,20 +765,22 @@ class TestExportRelation(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [self.span1.to_dict(), self.span2.to_dict()], |
|
|
|
"relations": [self.relation.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, "entities": [], "relations": []}, |
|
|
|
{**self.data2, "entities": [], "relations": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [ |
|
|
|
{ |
|
|
|
**self.data1, |
|
|
|
"entities": [self.span3.to_dict()], |
|
|
|
"relations": [], |
|
|
|
"Comments": [self.comment2.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, "entities": [], "relations": []}, |
|
|
|
{**self.data2, "entities": [], "relations": [], "Comments": []}, |
|
|
|
], |
|
|
|
self.project.approver.username: [ |
|
|
|
{**self.data1, "entities": [], "relations": []}, |
|
|
|
{**self.data2, "entities": [], "relations": []}, |
|
|
|
{**self.data1, "entities": [], "relations": [], "Comments": []}, |
|
|
|
{**self.data2, "entities": [], "relations": [], "Comments": []}, |
|
|
|
], |
|
|
|
} |
|
|
|
for username, dataset in expected_datasets.items(): |
|
|
@ -749,8 +794,9 @@ class TestExportRelation(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [self.span1.to_dict(), self.span2.to_dict(), self.span3.to_dict()], |
|
|
|
"relations": [self.relation.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict(), self.comment2.to_dict()], |
|
|
|
}, |
|
|
|
{**self.data2, "entities": [], "relations": []}, |
|
|
|
{**self.data2, "entities": [], "relations": [], "Comments": []}, |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |
|
|
|
|
|
|
@ -763,6 +809,7 @@ class TestExportRelation(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [self.span1.to_dict(), self.span2.to_dict()], |
|
|
|
"relations": [self.relation.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict()], |
|
|
|
}, |
|
|
|
], |
|
|
|
self.project.annotator.username: [], |
|
|
@ -779,6 +826,7 @@ class TestExportRelation(TestExport): |
|
|
|
**self.data1, |
|
|
|
"entities": [self.span1.to_dict(), self.span2.to_dict(), self.span3.to_dict()], |
|
|
|
"relations": [self.relation.to_dict()], |
|
|
|
"Comments": [self.comment1.to_dict(), self.comment2.to_dict()], |
|
|
|
} |
|
|
|
] |
|
|
|
self.assertEqual(dataset, expected_dataset) |